Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
James 2012-09-10 11:28:52 -04:00
commit 6e4b27f1ba
391 changed files with 323 additions and 138592 deletions

View File

@ -29,4 +29,29 @@ class Application_Common_Database
}
return $rows;
}
/*
Wrapper around prepareAndExecute that allows you to use multipe :xx's
in one query. Transforms $sql to :xx1, :xx2, ....
*/
public static function smartPrepareAndExecute($sql, array $params,
$type='all', $fetchType=PDO::FETCH_ASSOC)
{
$new_params = array();
$new_sql = $sql;
foreach ($params as $k => $v) {
$matches_count = substr_count($sql, $k);
if ($matches_count == 0) {
throw new Exception("Argument $k is not inside $sql");
} elseif ($matches_count == 1) {
$new_params[$k] = $new_params[$v];
} else {
foreach ( range(1,$matches_count) as $i ) {
preg_replace( "/$k(\D)/", "$k.$i${1}", $sql, 1);
$new_params[ $k.$i ] = $v;
}
}
}
return Application_Common_Database::prepareAndExecute( $new_sql,
$new_params, $type, $fetchType);
}
}

View File

@ -371,15 +371,15 @@ class ApiController extends Zend_Controller_Action
public function recordedShowsAction()
{
$today_timestamp = date("Y-m-d H:i:s");
$now = new DateTime($today_timestamp);
$end_timestamp = $now->add(new DateInterval("PT2H"));
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
$now = new DateTime($today_timestamp);
$end_timestamp = $now->add(new DateInterval("PT2H"));
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
$this->view->shows =
Application_Model_Show::getShows(
Application_Common_DateHelper::ConvertToUtcDateTime($today_timestamp, date_default_timezone_get()),
Application_Common_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()),
$excludeInstance = null, $onlyRecord = true);
$onlyRecord = true);
$this->view->is_recording = false;
$this->view->server_timezone = Application_Model_Preference::GetTimezone();

View File

@ -88,7 +88,7 @@ class Application_Model_RabbitMq
$temp['server_timezone'] = Application_Model_Preference::GetTimezone();
if ($event_type == "update_recorder_schedule") {
$temp['shows'] = Application_Model_Show::getShows($now,
$end_timestamp, $excludeInstance=NULL, $onlyRecord=TRUE);
$end_timestamp, $onlyRecord=TRUE);
}
$data = json_encode($temp);
$msg = new AMQPMessage($data, array('content_type' => 'text/plain'));

View File

@ -84,6 +84,10 @@ class Application_Model_Show
return $show->getDbUrl();
}
/*TODO : This method is not actually used anywhere as far as I can tell. We
can safely remove it and probably many other superfluous methods.
--RG*/
public function setUrl($p_url)
{
$show = CcShowQuery::create()->findPK($this->_showId);
@ -178,29 +182,30 @@ class Application_Model_Show
->filterByDbShowId($this->_showId)
->find($con);
/* Check if the show being resized and any of its repeats
* overlap with other scheduled shows
*/
/* Check if the show being resized and any of its repeats * overlap
with other scheduled shows */
foreach ($showInstances as $si) {
$startsDateTime = new DateTime($si->getDbStarts(), new DateTimeZone("UTC"));
$endsDateTime = new DateTime($si->getDbEnds(), new DateTimeZone("UTC"));
$endsDateTime = new DateTime($si->getDbEnds(), new DateTimeZone("UTC"));
/* The user is moving the show on the calendar from the perspective of local time.
* incase a show is moved across a time change border offsets should be added to the local
* timestamp and then converted back to UTC to avoid show time changes
*/
/* The user is moving the show on the calendar from the perspective
of local time. * incase a show is moved across a time change
border offsets should be added to the local * timestamp and
then converted back to UTC to avoid show time changes */
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$newStartsDateTime = Application_Model_ShowInstance::addDeltas($startsDateTime, $deltaDay, $deltaMin);
$newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin);
$newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin);
//convert our new starts/ends to UTC.
$newStartsDateTime->setTimezone(new DateTimeZone("UTC"));
$newEndsDateTime->setTimezone(new DateTimeZone("UTC"));
$newStartsDateTime->setTimezone($utc);
$newEndsDateTime->setTimezone($utc);
$overlapping = Application_Model_Schedule::checkOverlappingShows(
$newStartsDateTime, $newEndsDateTime, true, $si->getDbId());
$overlapping = Application_Model_Schedule::checkOverlappingShows($newStartsDateTime,
$newEndsDateTime, true, $si->getDbId());
if ($overlapping) {
return "Cannot schedule overlapping shows.\nNote: Resizing a repeating show ".
"affects all of its repeats.";
@ -208,39 +213,23 @@ class Application_Model_Show
}
$hours = $deltaMin/60;
if ($hours > 0) {
$hours = floor($hours);
} else {
$hours = ceil($hours);
}
$mins = abs($deltaMin%60);
$hours = ($hours > 0) ? floor($hours) : ceil($hours);
$mins = abs($deltaMin % 60);
//current timesamp in UTC.
$current_timestamp = gmdate("Y-m-d H:i:s");
//update all cc_show_instances that are in the future.
$sql = "UPDATE cc_show_instances
SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')
WHERE (show_id = {$this->_showId} AND ends > '$current_timestamp')
AND ((ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}' - starts) <= interval '24:00');";
//update cc_show_days so future shows can be created with the new duration.
//only setting new duration if it is less than or equal to 24 hours.
$sql = $sql . "
UPDATE cc_show_days SET duration = (CAST(duration AS interval) + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')
WHERE show_id = {$this->_showId}
AND ((CAST(duration AS interval) + interval '{$deltaDay} days' + interval '{$hours}:{$mins}') <= interval '24:00')";
$sql_gen = <<<SQL
UPDATE cc_show_instances
UPDATE cc_show_instances
SET ends = (ends + interval :deltaDay1 + interval :interval1)
WHERE (show_id = :show_id1 AND ends > :current_timestamp1)
AND ((ends + interval :deltaDay2 + interval :interval2 - starts) <= interval '24:00')
WHERE (show_id = :show_id1
AND ends > :current_timestamp1)
AND ((ends + interval :deltaDay2 + interval :interval2 - starts) <= interval '24:00')
UPDATE cc_show_days SET duration = (CAST(duration AS interval) + interval :deltaDay3 + interval :interval3)
UPDATE cc_show_days
SET duration = (CAST(duration AS interval) + interval :deltaDay3 + interval :interval3)
WHERE show_id = :show_id2
AND ((CAST(duration AS interval) + interval :deltaDay4 + interval :interval4) <= interval '24:00')
AND ((CAST(duration AS interval) + interval :deltaDay4 + interval :interval4) <= interval '24:00')
SQL;
Application_Common_Database::prepareAndExecute($sql_gen,
@ -258,9 +247,6 @@ SQL;
':interval4' => "$hours:$mins"
), "execute");
//do both the queries at once.
//$con->exec($sql);
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$con->beginTransaction();
@ -308,7 +294,9 @@ SQL;
->findOne();
if (is_null($showInstancesRow)) {
$sql = "DELETE FROM cc_show WHERE id = {$this->_showId}";
$sql = "DELETE FROM cc_show WHERE id = :show_id";
Application_Common_Database::prepareAndExecute(
$sql, array( 'show_id' => $this->_showId ), "execute");
$con->exec($sql);
}
@ -366,14 +354,22 @@ SQL;
$uncheckedDaysImploded = implode(",", $daysRemovedUTC);
$showId = $this->getId();
$esc_uncheckedDays = pg_escape_string($uncheckedDaysImploded);
$timestamp = gmdate("Y-m-d H:i:s");
$sql = "DELETE FROM cc_show_instances"
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
." AND starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId";
$sql = <<<SQL
DELETE
FROM cc_show_instances
WHERE EXTRACT(DOW FROM starts) IN ($esc_uncheckedDays)
AND starts > :timestamp::TIMESTAMP
AND show_id = :showId
SQL;
$con->exec($sql);
Application_Common_Database::prepareAndExecute( $sql,
array(
":timestamp" => $timestamp,
":showId" => $showId,
), "execute");
}
/**
@ -422,27 +418,38 @@ SQL;
*/
public function getRebroadcastsAbsolute()
{
$con = Propel::getConnection();
$sql = <<<SQL
SELECT starts
FROM cc_show_instances
WHERE instance_id =
(SELECT id
FROM cc_show_instances
WHERE show_id = :showId
ORDER BY starts LIMIT 1)
AND rebroadcast = 1
ORDER BY starts
SQL;
$showId = $this->getId();
$sql = "SELECT starts FROM cc_show_instances "
."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::info($sql);
$rebroadcasts = $con->query($sql)->fetchAll();
$rebroadcasts = Application_Common_Database::prepareAndExecute( $sql,
array( 'showId' => $this->getId() ), 'all' );
$rebroadcastsLocal = array();
//get each rebroadcast show in cc_show_instances, convert to current timezone to get start date/time.
/*TODO: refactor the following code to get rid of the $i temporary
variable. -- RG*/
$i = 0;
foreach ($rebroadcasts as $show) {
$startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC"));
$startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$rebroadcastsLocal[$i]["start_date"] = $startDateTime->format("Y-m-d");
$rebroadcastsLocal[$i]["start_time"] = $startDateTime->format("H:i");
$utc = new DateTimeZone("UTC");
$dtz = new DateTimeZone( date_default_timezone_get() );
foreach ($rebroadcasts as $show) {
$startDateTime = new DateTime($show["starts"], $utc);
$startDateTime->setTimezone($dtz);
$rebroadcastsLocal[$i]["start_date"] =
$startDateTime->format("Y-m-d");
$rebroadcastsLocal[$i]["start_time"] =
$startDateTime->format("H:i");
$i = $i + 1;
}
@ -460,14 +467,15 @@ SQL;
*/
public function getRebroadcastsRelative()
{
$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 $con->query($sql)->fetchAll();
$sql = <<<SQL
SELECT day_offset,
start_time
FROM cc_show_rebroadcast
WHERE show_id = :showId
ORDER BY day_offset
SQL;
return Application_Common_Database::prepareAndExecute( $sql,
array( ':showId' => $this->getId() ), 'all' );
}
/**
@ -519,15 +527,18 @@ SQL;
*/
public function getRepeatingEndDate()
{
$con = Propel::getConnection();
$sql = <<<SQL
SELECT last_show
FROM cc_show_days
WHERE show_id = :showId
ORDER BY last_show DESC
SQL;
$showId = $this->getId();
$sql = "SELECT last_show FROM cc_show_days"
." WHERE show_id = $showId"
." ORDER BY last_show DESC";
$query = $con->query($sql)->fetchColumn(0);
$query = Application_Common_Database::prepareAndExecute( $sql,
array( 'showId' => $this->getId() ), 'column' );
/* TODO: Why return empty string instead of false? very confusing --RG
*/
return ($query !== false) ? $query : "";
}
@ -543,16 +554,15 @@ SQL;
*/
public function deleteAllInstances()
{
$con = Propel::getConnection();
$timestamp = gmdate("Y-m-d H:i:s");
$showId = $this->getId();
$sql = "DELETE FROM cc_show_instances"
." WHERE starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId";
$con->exec($sql);
$sql = <<<SQL
DELETE
FROM cc_show_instances
WHERE starts > :timestamp::TIMESTAMP
AND show_id = :showId
SQL;
Application_Common_Database::prepareAndExecute( $sql,
array( ':timestamp' => gmdate("Y-m-d H:i:s"),
':showId' => $this->getId()), 'execute');
}
/**
@ -561,15 +571,16 @@ SQL;
*/
public function deleteAllRebroadcasts()
{
$con = Propel::getConnection();
$timestamp = gmdate("Y-m-d H:i:s");
$showId = $this->getId();
$sql = "DELETE FROM cc_show_instances"
." WHERE starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId"
." AND rebroadcast = 1";
$sql = <<<SQL
DELETE
FROM cc_show_instances
WHERE starts > :timestamp::TIMESTAMP
AND show_id :showId
AND rebroadcast 1
SQL;
Application_Common_Database::prepareAndExecute( $sql,
array( ':showId' => $this->getId(),
':timestamp' => gmdate("Y-m-d H:i:s")), 'execute');
$con->exec($sql);
}
@ -652,8 +663,6 @@ SQL;
$stmt->bindParam(':showId', $showId);
$stmt->execute();
//$query = $con->query($sql);
if (!$stmt) {
return "";
}
@ -759,25 +768,20 @@ SQL;
*/
public function getAllFutureInstanceIds()
{
$con = Propel::getConnection();
$sql = <<<SQL
SELECT id
FROM cc_show_instances
WHERE show_id :showId
AND starts > :timestamp::TIMESTAMP
AND modified_instance != TRUE
SQL;
$rows = Application_Common_Database::prepareAndExecute($sql,
array( ':showId' => $this->getId(),
':timestamp' => gmdate("Y-m-d H:i:s")), "all");
$date = new Application_Common_DateHelper;
$timestamp = $date->getTimestamp();
$showId = $this->getId();
$sql = "SELECT id from cc_show_instances"
." WHERE show_id = $showId"
." AND starts > TIMESTAMP '$timestamp'"
." AND modified_instance != TRUE";
$rows = $con->query($sql)->fetchAll();
$instance_ids = array();
foreach ($rows as $row) {
$instance_ids[] = $row["id"];
}
return $instance_ids;
return array_map( function($i) {
return $i['id'];
}, $rows);
}
/* Called when a show's duration is changed (edited).
@ -805,12 +809,11 @@ SQL;
$sql = <<<SQL
UPDATE cc_show_instances
UPDATE cc_show_instances
SET ends = starts + :add_show_duration::INTERVAL
WHERE show_id = :show_id
AND ends > :timestamp::TIMESTAMP
AND ends > :timestamp::TIMESTAMP
SQL;
Application_Common_Database::prepareAndExecute( $sql, array(
':add_show_duration' => $p_data['add_show_duration'],
@ -874,14 +877,11 @@ SQL;
public function getShowDays()
{
$showDays = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->find();
$days = array();
foreach ($showDays as $showDay) {
array_push($days, $showDay->getDbDay());
}
return $days;
$showDays = CcShowDaysQuery::create()->filterByDbShowId(
$this->getId())->find();
return array_map( function($showDay) {
return $showDay->getDbDay();
}, $showDays);
}
/* Only used for shows that aren't repeating.
@ -911,7 +911,7 @@ SQL;
public function getLiveStreamInfo()
{
$info = array();
if ($this->_showId == null) {
if ($this->getId() == null) {
return $info;
} else {
$ccShow = CcShowQuery::create()->findPK($this->_showId);
@ -920,7 +920,6 @@ SQL;
$info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth();
$info['custom_username'] = $ccShow->getDbLiveStreamUser();
$info['custom_password'] = $ccShow->getDbLiveStreamPass();
return $info;
}
}
@ -950,20 +949,24 @@ SQL;
* row in the cc_show_instances table. */
public function getInstanceOnDate($p_dateTime)
{
$con = Propel::getConnection();
$timestamp = $p_dateTime->format("Y-m-d H:i:s");
$showId = $this->getId();
$sql = "SELECT id FROM cc_show_instances"
." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
." AND show_id = $showId AND rebroadcast = 0";
$query = $con->query($sql);
$row = ($query !== false) ? $query->fetchColumn(0) : null;
return CcShowInstancesQuery::create()
->findPk($row);
$sql = <<<SQL
SELECT id
FROM cc_show_instances
WHERE date(starts) = date(TIMESTAMP :timestamp)
AND show_id = :showId
AND rebroadcast = 0;
SQL;
try {
$row = Application_Common_Database::prepareAndExecute( $sql,
array( 'showId' => $this->getId(),
':timestamp' => $timestamp ), 'column');
return CcShowInstancesQuery::create()
->findPk($row);
} catch (Exception $e) {
return null;
}
}
public function deletePossiblyInvalidInstances($p_data, $p_endDate, $isRecorded, $repeatType)
@ -1173,6 +1176,8 @@ SQL;
->delete();
}
//adding rows to cc_show_rebroadcast
/* TODO: Document magic constant 10 and define it properly somewhere
--RG */
if (($isRecorded && $data['add_show_rebroadcast']) && ($repeatType != -1)) {
for ($i=1; $i<=10; $i++) {
if ($data['add_show_rebroadcast_date_'.$i]) {
@ -1186,10 +1191,21 @@ SQL;
} elseif ($isRecorded && $data['add_show_rebroadcast'] && ($repeatType == -1)) {
for ($i=1; $i<=10; $i++) {
if ($data['add_show_rebroadcast_date_absolute_'.$i]) {
$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
$sql = "SELECT date '{$data['add_show_rebroadcast_date_absolute_'.$i]}' - date '{$data['add_show_start_date']}' ";
$r = $con->query($sql);
$offset_days = $r->fetchColumn(0);
//$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
//$sql = "SELECT date '{$data['add_show_rebroadcast_date_absolute_'.$i]}' - date '{$data['add_show_start_date']}' ";
$sql = <<<SQL
SELECT date :rebroadcast - date :start
SQL;
$offset_days =
Application_Common_Database::prepareAndExecute($sql,
array(
'rebroadcast' =>
$date["add_show_rebroadcast_date_absolute_$i"],
'start' =>
$date['add_show_start_date']), "column" );
//$r = $con->query($sql);
//$offset_days = $r->fetchColumn(0);
$showRebroad = new CcShowRebroadcast();
$showRebroad->setDbDayOffset($offset_days." days");
@ -1588,7 +1604,7 @@ SQL;
* @param boolean $onlyRecord
* @return array
*/
public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE)
public static function getShows($start_timestamp, $end_timestamp, $onlyRecord=FALSE)
{
$con = Propel::getConnection();
@ -1600,42 +1616,56 @@ SQL;
Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp);
}
$sql = "SELECT si1.starts AS starts, si1.ends AS ends, si1.record AS record, si1.rebroadcast AS rebroadcast, si2.starts AS parent_starts,
si1.instance_id AS record_id, si1.show_id AS show_id, show.name AS name,
show.color AS color, show.background_color AS background_color, si1.file_id AS file_id, si1.id AS instance_id,
si1.created AS created, si1.last_scheduled AS last_scheduled, si1.time_filled AS time_filled, f.soundcloud_id
FROM cc_show_instances AS si1
LEFT JOIN cc_show_instances AS si2 ON si1.instance_id = si2.id
LEFT JOIN cc_show AS show ON show.id = si1.show_id
LEFT JOIN cc_files AS f ON f.id = si1.file_id
WHERE si1.modified_instance = FALSE";
$sql = <<<SQL
SELECT si1.starts AS starts,
si1.ends AS ends,
si1.record AS record,
si1.rebroadcast AS rebroadcast,
si2.starts AS parent_starts,
si1.instance_id AS record_id,
si1.show_id AS show_id,
show.name AS name,
show.color AS color,
show.background_color AS background_color,
si1.file_id AS file_id,
si1.id AS instance_id,
si1.created AS created,
si1.last_scheduled AS last_scheduled,
si1.time_filled AS time_filled,
f.soundcloud_id
FROM cc_show_instances AS si1
LEFT JOIN cc_show_instances AS si2 ON si1.instance_id = si2.id
LEFT JOIN cc_show AS show ON show.id = si1.show_id
LEFT JOIN cc_files AS f ON f.id = si1.file_id
WHERE si1.modified_instance = FALSE
SQL;
//only want shows that are starting at the time or later.
$start_string = $start_timestamp->format("Y-m-d H:i:s");
$end_string = $end_timestamp->format("Y-m-d H:i:s");
if ($onlyRecord) {
$sql .= " AND (si1.starts >= :start::TIMESTAMP AND si1.starts < :end::TIMESTAMP)";
$sql .= " AND (si1.record = 1)";
return Application_Common_Database::prepareAndExecute( $sql,
array( ':start' => $start_string,
':end' => $end_string ), 'all');
$sql = $sql." AND (si1.starts >= '{$start_string}' AND si1.starts < timestamp '{$end_string}')";
$sql = $sql." AND (si1.record = 1)";
} else {
$sql = $sql." AND ((si1.starts >= '{$start_string}' AND si1.starts < '{$end_string}')
OR (si1.ends > '{$start_string}' AND si1.ends <= '{$end_string}')
OR (si1.starts <= '{$start_string}' AND si1.ends >= '{$end_string}'))";
$sql .= " ". <<<SQL
AND ((si1.starts >= :start1::TIMESTAMP AND si1.starts < :end1::TIMESTAMP)
OR (si1.ends > :start2::TIMESTAMP AND si1.ends <= :end2::TIMESTAMP)
OR (si1.starts <= :start3::TIMESTAMP AND si1.ends >= :end3::TIMESTAMP))
SQL;
return Application_Common_Database::prepareAndExecute( $sql,
array(
'start1' => $start_string,
'start2' => $start_string,
'start3' => $start_string,
'end1' => $end_string,
'end2' => $end_string,
'end3' => $end_string
), 'all');
}
if (isset($excludeInstance)) {
foreach ($excludeInstance as $instance) {
$sql_exclude[] = "si1.id != {$instance}";
}
$exclude = join(" OR ", $sql_exclude);
$sql = $sql." AND ({$exclude})";
}
$result = $con->query($sql)->fetchAll();
return $result;
}
private static function setNextPop($next_date, $show_id, $day)
@ -1696,10 +1726,10 @@ SQL;
*/
public static function &getFullCalendarEvents($p_start, $p_end, $p_editable=false)
{
$events = array();
$events = array();
$interval = $p_start->diff($p_end);
$days = $interval->format('%a');
$shows = Application_Model_Show::getShows($p_start, $p_end);
$days = $interval->format('%a');
$shows = Application_Model_Show::getShows($p_start, $p_end);
$nowEpoch = time();
$timezone = date_default_timezone_get();
@ -2076,7 +2106,6 @@ SQL;
throw new Exception("Error: $msg");
}
return $rows;
}
/**
@ -2102,20 +2131,16 @@ SQL;
public static function getMaxLengths()
{
global $CC_CONFIG;
$con = Propel::getConnection();
//Not using prepared statement here since not using an variable input.
$sql = "SELECT column_name, character_maximum_length FROM information_schema.columns"
." WHERE table_name = 'cc_show' AND character_maximum_length > 0";
$result = $con->query($sql)->fetchAll();
// store result into assoc array
$sql = <<<SQL
SELECT column_name, character_maximum_length FROM information_schema.columns
WHERE table_name = 'cc_show' AND character_maximum_length > 0
SQL;
$result = $con->query($sql)->fetchAll();
$assocArray = array();
foreach ($result as $row) {
$assocArray[$row['column_name']] = $row['character_maximum_length'];
}
return $assocArray;
}
}

View File

@ -22,6 +22,8 @@ class Application_Model_ShowInstance
return $this->_showInstance->getDbShowId();
}
/* TODO: A little inconsistent because other models have a getId() method
to get PK --RG */
public function getShowInstanceId()
{
return $this->_instanceId;
@ -167,26 +169,33 @@ class Application_Model_ShowInstance
$con = Propel::getConnection();
$instance_id = $this->getShowInstanceId();
$sql = "SELECT starts from cc_schedule"
." WHERE instance_id = $instance_id"
." ORDER BY starts"
." LIMIT 1";
$scheduleStarts = $con->query($sql)->fetchColumn(0);
$sql = <<<SQL
SELECT starts
FROM cc_schedule
WHERE instance_id = :instanceId
ORDER BY starts LIMIT 1;
SQL;
$scheduleStarts = Application_Common_Database::prepareAndExecute( $sql,
array( ':instanceId' => $instance_id ), 'column' );
if ($scheduleStarts) {
$scheduleStartsEpoch = strtotime($scheduleStarts);
$showStartsEpoch = strtotime($this->getShowInstanceStart());
$showStartsEpoch = strtotime($this->getShowInstanceStart());
$diff = $showStartsEpoch - $scheduleStartsEpoch;
if ($diff != 0) {
$sql = "UPDATE cc_schedule"
." SET starts = starts + INTERVAL '$diff' second,"
." ends = ends + INTERVAL '$diff' second"
." WHERE instance_id = $instance_id";
$con->exec($sql);
$sql = <<<SQL
UPDATE cc_schedule
SET starts = starts + INTERVAL :diff1 SECOND,
ends = ends + INTERVAL :diff2 SECOND
WHERE instance_id = :instanceId
SQL;
Application_Common_Database::prepareAndExecute($sql,
array(
':diff1' => $diff,
':diff2' => $diff,
':instanceId' => $instance_id ), 'execute');
}
}
Application_Model_RabbitMq::PushSchedule();
@ -745,69 +754,56 @@ SQL;
public static function GetLastShowInstance($p_timeNow)
{
global $CC_CONFIG;
$con = Propel::getConnection();
$sql = <<<SQL
SELECT si.id
FROM cc_show_instances si
WHERE si.ends < :timeNow::TIMESTAMP
AND si.modified_instance = 'f'
ORDER BY si.ends DESC LIMIT 1;
SQL;
$id = Application_Common_Database( $sql, array(
':timeNow' => $p_timeNow ), 'column' );
$sql = "SELECT si.id"
." FROM $CC_CONFIG[showInstances] si"
." WHERE si.ends < TIMESTAMP '$p_timeNow'"
." AND si.modified_instance = 'f'"
." ORDER BY si.ends DESC"
." LIMIT 1";
$id = $con->query($sql)->fetchColumn(0);
if ($id) {
return new Application_Model_ShowInstance($id);
} else {
return null;
}
return ($id ? new Application_Model_ShowInstance($id) : null );
}
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
* this case, the show that started later is the one that
* is actually playing, and so this is the one we want.
*/
$sql = "SELECT si.id"
." FROM $CC_CONFIG[showInstances] si"
." WHERE si.starts <= TIMESTAMP '$p_timeNow'"
." AND si.ends > TIMESTAMP '$p_timeNow'"
." AND si.modified_instance = 'f'"
." ORDER BY si.starts DESC"
." LIMIT 1";
$sql = <<<SQL
SELECT si.id
FROM cc_show_instances si
WHERE si.starts <= :timeNow1::TIMESTAMP
AND si.ends > :timeNow2::TIMESTAMP
AND si.modified_instance = 'f'
ORDER BY si.starts DESC LIMIT 1
SQL;
$id = $con->query($sql)->fetchColumn(0);
if ($id) {
return new Application_Model_ShowInstance($id);
} else {
return null;
}
$id = Application_Common_Database( $sql, array(
':timeNow1' => $p_timeNow,
':timeNow2' => $p_timeNow ), 'column');
return ( $id ? new Application_Model_ShowInstance($id) : null );
}
public static function GetNextShowInstance($p_timeNow)
{
global $CC_CONFIG;
$con = Propel::getConnection();
$sql = "SELECT si.id"
." FROM $CC_CONFIG[showInstances] si"
." WHERE si.starts > TIMESTAMP '$p_timeNow'"
." AND si.modified_instance = 'f'"
." ORDER BY si.starts"
." LIMIT 1";
$id = $con->query($sql)->fetchColumn(0);
if ($id) {
return new Application_Model_ShowInstance($id);
} else {
return null;
}
$sql = <<<SQL
SELECT si.id
FROM cc_show_instances si
WHERE si.starts > :timeNow::TIMESTAMP
AND si.modified_instance = 'f'
ORDER BY si.starts
LIMIT 1
SQL;
$id = Application_Common_Database::prepareAndExecute( $sql,
array( 'timeNow' => $p_timeNow ), 'column' );
return ( $id ? new Application_Model_ShowInstance($id) : null );
}
// returns number of show instances that ends later than $day

View File

@ -413,8 +413,10 @@ class Application_Model_StoredFile
return "ogg";
} elseif ($mime == "audio/mp3" || $mime == "audio/mpeg") {
return "mp3";
} elseif ($mime == "audio/x/flac") {
} elseif ($mime == "audio/x-flac") {
return "flac";
} else {
throw new Exception("Unknown $mime");
}
}

4
debian/control vendored
View File

@ -37,10 +37,12 @@ Depends: apache2,
php-pear,
php5-pgsql,
python,
pwgen,
rabbitmq-server,
sudo,
sysv-rc,
tar (>= 1.22),
coreutils (>= 7.5) | timeout,
unzip,
vorbis-tools,
zendframework | libzend-framework-php,
@ -48,7 +50,7 @@ Depends: apache2,
Recommends: icecast2
Suggests: airtime-audio-samples,
alsa-utils
Description: The open radio software for scheduling and remote station management.
Description: open radio software for scheduling and remote station management.
Airtime is an open source application that provides remote automation
of a radio station.
.

View File

@ -5,7 +5,7 @@
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
if(posix_geteuid() != 0) {
if (posix_geteuid() != 0) {
echo "Must be root user.\n";
exit(1);
}
@ -13,9 +13,9 @@ if(posix_geteuid() != 0) {
require_once(__DIR__.'/airtime-constants.php');
require_once(__DIR__.'/AirtimeIni.php');
require_once(__DIR__.'/AirtimeInstall.php');
require_once 'propel/runtime/lib/Propel.php';
require_once 'propel/runtime/lib/Propel.php';
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/db-conf.php");
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
function pause()
@ -23,7 +23,7 @@ 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. */
if (getenv("AIRTIME_INSTALL_DEBUG") === "1"){
if (getenv("AIRTIME_INSTALL_DEBUG") === "1") {
echo "Press Enter to Continue".PHP_EOL;
fgets(STDIN);
}
@ -44,7 +44,7 @@ $database = $CC_CONFIG['dsn']['database'];
$airtime_version = AIRTIME_VERSION;
$target_dir = trim(getenv("HOME"));
if (strlen($target_dir) == 0){
if (strlen($target_dir) == 0) {
$target_dir = "/tmp";
}
@ -52,7 +52,7 @@ $target_file = "/airtime_$airtime_version.sql";
$target_path = $target_dir.$target_file;
echo "* Backing up current database to $target_path".PHP_EOL;
exec("export PGPASSWORD=$password && pg_dump -h $host -U $user -f $target_path $database", $arr, $return_code);
if ($return_code == 0){
if ($return_code == 0) {
echo " * Success".PHP_EOL;
} else {
echo " * Failed".PHP_EOL;
@ -64,59 +64,39 @@ $version = substr($version, 0, 5);
$SCRIPTPATH = __DIR__;
if (strcmp($version, "1.9.0") < 0){
echo "Unsupported Airtime version. You must upgrade from at least Airtime 1.9.0.".PHP_EOL;
if (strcmp($version, "2.0.0") < 0) {
echo "Unsupported Airtime version. You must upgrade from at least Airtime 2.0.0.".PHP_EOL;
exit(1);
}
if (strcmp($version, "1.9.2") < 0){
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-1.9.2/airtime-upgrade.php");
pause();
}
if (strcmp($version, "1.9.3") < 0){
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-1.9.3/airtime-upgrade.php");
pause();
}
if (strcmp($version, "1.9.4") < 0){
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-1.9.4/airtime-upgrade.php");
pause();
}
if (strcmp($version, "1.9.5") < 0){
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-1.9.5/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.0.0") < 0){
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.0.0/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.0.1") < 0){
if (strcmp($version, "2.0.1") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.0.1/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.0.2") < 0){
if (strcmp($version, "2.0.2") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.0.2/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.0.3") < 0){
if (strcmp($version, "2.0.3") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.0.3/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.1.0") < 0){
if (strcmp($version, "2.1.0") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.1.0/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.1.1") < 0){
if (strcmp($version, "2.1.1") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.1.1/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.1.2") < 0){
if (strcmp($version, "2.1.2") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.1.2/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.1.3") < 0){
if (strcmp($version, "2.1.3") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.1.3/airtime-upgrade.php");
pause();
}
if (strcmp($version, "2.2.0") < 0){
if (strcmp($version, "2.2.0") < 0) {
passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.2.0/airtime-upgrade.php");
pause();
}

View File

@ -1,56 +0,0 @@
<?php
/**
* @package Airtime
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
require_once(dirname(__FILE__).'/../../include/AirtimeIni.php');
require_once(dirname(__FILE__).'/../../include/AirtimeInstall.php');
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
function CreateIniFiles()
{
global $AIRTIME_PYTHON_APPS;
if (!file_exists("/etc/airtime/")){
if (!mkdir("/etc/airtime/", 0755, true)){
echo "Could not create /etc/airtime/ directory. Exiting.";
exit(1);
}
}
if (!copy("airtime.conf.170", CONF_FILE_AIRTIME)){
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy($AIRTIME_PYTHON_APPS."/pypo/pypo.cfg", CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy($AIRTIME_PYTHON_APPS."/show-recorder/recorder.cfg", CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy($AIRTIME_PYTHON_APPS."/pypo/liquidsoap_scripts/liquidsoap.cfg", CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
exit(1);
}
}
CreateIniFiles();
AirtimeIni::UpdateIniFiles();
echo PHP_EOL."*** Updating Database Tables ***".PHP_EOL;
AirtimeInstall::MigrateTablesToVersion(__DIR__, '20110402164819');
echo PHP_EOL."*** Updating Pypo ***".PHP_EOL;
system("python ".__DIR__."/../../../python_apps/pypo/install/pypo-install.py");
echo PHP_EOL."*** Recorder Installation ***".PHP_EOL;
system("python ".__DIR__."/../../../python_apps/show-recorder/install/recorder-install.py");

View File

@ -1,22 +0,0 @@
[database]
host = localhost
dbname = airtime
dbuser = airtime
dbpass = airtime
[rabbitmq]
host = 127.0.0.1
port = 5672
user = guest
password = guest
vhost = /
[general]
api_key = AAA
web_server_user = www-data
airtime_dir = x
base_files_dir = x
[soundcloud]
connection_retries = 3
time_between_retries = 60

View File

@ -1,269 +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());
require_once(dirname(__FILE__).'/../../include/AirtimeInstall.php');
global $CC_CONFIG;
function load_airtime_config(){
$ini_array = parse_ini_file('/etc/airtime/airtime.conf', true);
return $ini_array;
}
$values = load_airtime_config();
$CC_CONFIG = array(
// Name of the web server user
'webServerUser' => $values['general']['web_server_user'],
'rabbitmq' => $values['rabbitmq'],
'baseFilesDir' => $values['general']['base_files_dir'],
// main directory for storing binary media files
'storageDir' => $values['general']['base_files_dir']."/stor",
// Database config
'dsn' => array(
'username' => $values['database']['dbuser'],
'password' => $values['database']['dbpass'],
'hostspec' => $values['database']['host'],
'phptype' => 'pgsql',
'database' => $values['database']['dbname']),
// prefix for table names in the database
'tblNamePrefix' => 'cc_',
/* ================================================ storage configuration */
'apiKey' => array($values['general']['api_key']),
'apiPath' => '/api/',
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
'soundcloud-connection-retries' => $values['soundcloud']['connection_retries'],
'soundcloud-connection-wait' => $values['soundcloud']['time_between_retries'],
"rootDir" => __DIR__."/../.."
);
AirtimeInstall::DbConnect(true);
$con = Propel::getConnection();
echo PHP_EOL."*** Updating Database Tables ***".PHP_EOL;
if(AirtimeInstall::DbTableExists('doctrine_migration_versions') === false) {
$migrations = array('20110312121200', '20110331111708', '20110402164819');
foreach($migrations as $migration) {
AirtimeInstall::BypassMigrations(__DIR__, $migration);
}
}
AirtimeInstall::MigrateTablesToVersion(__DIR__, '20110406182005');
//setting data for new aggregate show length column.
$sql = "SELECT id FROM cc_show_instances";
$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"]}";
$con->exec($sql);
}
//end setting data for new aggregate show length column.
exec("rm -fr /opt/pypo");
exec("rm -fr /opt/recorder");
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";
$configFiles = array(CONF_FILE_AIRTIME,
CONF_FILE_PYPO,
CONF_FILE_RECORDER,
CONF_FILE_LIQUIDSOAP);
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
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", CONF_FILE_AIRTIME)){
echo "Could not copy airtime.conf.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/pypo.cfg.$suffix", CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/recorder.cfg.$suffix", CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/liquidsoap.cfg.$suffix", CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
}
function ReadPythonConfig($p_filename)
{
$values = array();
$lines = file($p_filename);
$n=count($lines);
for ($i=0; $i<$n; $i++) {
if (strlen($lines[$i]) && !in_array(substr($lines[$i], 0, 1), array('#', PHP_EOL))){
$info = explode("=", $lines[$i]);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n=count($lines);
foreach ($lines as &$line) {
if ($line[0] != "#"){
$key_value = split("=", $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);
}
function MergeConfigFiles($configFiles, $suffix)
{
foreach ($configFiles as $conf) {
if (file_exists("$conf$suffix.bak")) {
if($conf === CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
$oldSettings['general']['airtime_dir'] = '/var/www/airtime';
$oldSettings['general']['base_files_dir'] = '/srv/airtime';
}
else {
$newSettings = ReadPythonConfig($conf);
$oldSettings = ReadPythonConfig("$conf$suffix.bak");
}
//override some values needed for 1.8.0.
if($conf === CONF_FILE_PYPO) {
$oldSettings['cache_dir'] = '/var/tmp/airtime/pypo/cache/';
$oldSettings['file_dir'] = '/var/tmp/airtime/pypo/files/';
$oldSettings['tmp_dir'] = '/var/tmp/airtime/pypo/tmp/';
}
else if($conf === CONF_FILE_RECORDER) {
$oldSettings['base_recorded_files'] = '/var/tmp/airtime/show-recorder/';
}
$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) {
if(isset($oldSettings[$section][$sectionKey])) {
UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
}
}
}
else {
UpdateIniValue($conf, $section, $oldSettings[$section]);
}
}
}
}
}
}
function LoadConfig($CC_CONFIG) {
$values = parse_ini_file(CONF_FILE_AIRTIME, true);
// Name of the web server user
$CC_CONFIG['webServerUser'] = $values['general']['web_server_user'];
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
$CC_CONFIG['rabbitmq'] = $values['rabbitmq'];
$CC_CONFIG['baseFilesDir'] = $values['general']['base_files_dir'];
// main directory for storing binary media files
$CC_CONFIG['storageDir'] = $values['general']['base_files_dir']."/stor";
// 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_CONFIG['apiKey'] = array($values['general']['api_key']);
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
return $CC_CONFIG;
}
function movePhpFiles($CC_CONFIG){
$phpDir = $CC_CONFIG['phpDir'];
echo "Copying Server files from $phpDir/airtime_mvc to /var/www/airtime";
exec("mkdir -p /var/www/airtime");
exec("cp -R $phpDir/airtime_mvc/* /var/www/airtime");
}
// Backup the config files
$suffix = date("Ymdhis")."-1.8.0";
foreach ($configFiles as $conf) {
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
exec("cp $conf $conf$suffix.bak");
}
}
$CC_CONFIG = LoadConfig($CC_CONFIG);
movePhpFiles($CC_CONFIG);
$default_suffix = "180";
CreateIniFiles($default_suffix);
echo "* Initializing INI files".PHP_EOL;
MergeConfigFiles($configFiles, $suffix);

View File

@ -1,22 +0,0 @@
[database]
host = localhost
dbname = airtime
dbuser = airtime
dbpass = airtime
[rabbitmq]
host = 127.0.0.1
port = 5672
user = guest
password = guest
vhost = /
[general]
api_key = AAA
web_server_user = www-data
airtime_dir = x
base_files_dir = x
[soundcloud]
connection_retries = 3
time_between_retries = 60

View File

@ -1,38 +0,0 @@
###########################################
# liquidsoap config file #
###########################################
###########################################
# general settings #
###########################################
log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"
log_level = 3
###########################################
# stream settings #
###########################################
icecast_host = "127.0.0.1"
icecast_port = 8000
icecast_pass = "hackme"
###########################################
# webstream mountpoint names #
###########################################
mount_point_mp3 = "airtime.mp3"
mount_point_vorbis = "airtime.ogg"
###########################################
# webstream metadata settings #
###########################################
icecast_url = "http://airtime.sourcefabric.org"
icecast_description = "Airtime Radio!"
icecast_genre = "genre"
###########################################
#liquidsoap output settings #
###########################################
output_sound_device = false
output_icecast_vorbis = true
output_icecast_mp3 = false

View File

@ -1,112 +0,0 @@
############################################
# pypo - configuration #
############################################
# Set the type of client you are using.
# Currently supported types:
# 1) "obp" = Open Broadcast Platform
# 2) "airtime"
#
api_client = "airtime"
############################################
# Cache Directories #
# *include* trailing slash !! #
############################################
cache_dir = '/var/tmp/airtime/pypo/cache/'
file_dir = '/var/tmp/airtime/pypo/files/'
tmp_dir = '/var/tmp/airtime/pypo/tmp/'
############################################
# Setup Directories #
# Do *not* include trailing slash !! #
############################################
cache_base_dir = '/var/tmp/airtime/pypo'
bin_dir = '/usr/lib/airtime/pypo'
log_base_dir = '/var/log/airtime'
pypo_log_dir = '/var/log/airtime/pypo'
liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap'
# Hostname
base_url = 'localhost'
base_port = 80
############################################
# Liquidsoap settings #
############################################
ls_host = '127.0.0.1'
ls_port = '1234'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
############################################
# pypo preferences #
############################################
prepare_ahead = 24 #in hours
cache_for = 24 #how long to hold the cache, in hours
# Poll interval in seconds.
#
# This will rarely need to be changed because any schedule changes are
# automatically sent to pypo immediately.
#
# This is how often the poll script downloads new schedules and files from the
# server in the event that no changes are made to the schedule.
#
poll_interval = 3600 # in seconds.
# Push interval in seconds.
#
# This is how often the push script checks whether it has something new to
# push to liquidsoap.
#
# It's hard to imagine a situation where this should be more than 1 second.
#
push_interval = 1 # in seconds
# 'pre' or 'otf'. 'pre' cues while playlist preparation
# while 'otf' (on the fly) cues while loading into ls
# (needs the post_processor patch)
cue_style = 'pre'
################################################################################
# Uncomment *one of the sets* of values from the API clients below, and comment
# out all the others.
################################################################################
#####################
# Airtime Config #
#####################
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
# Schedule export path.
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
export_url = 'schedule/api_key/%%api_key%%'
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
# Update whether a schedule group has begun playing.
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
# Update whether an audio clip is currently playing.
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
# ???
generate_range_url = 'generate_range_dp.php'

View File

@ -1,35 +0,0 @@
api_client = "airtime"
# Hostname
base_url = 'localhost'
base_port = 80
# where the binary files live
bin_dir = '/usr/lib/airtime/show-recorder'
# base path to store recordered shows at
base_recorded_files = '/var/tmp/airtime/show-recorder/'
# where the logging files live
log_dir = '/var/log/airtime/show-recorder'
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
# URL to get the schedule of shows set to record
show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
# URL to upload the recorded show's file to Airtime
upload_file_url = 'upload-recorded/format/json/api_key/%%api_key%%'
#number of retries to upload file if connection problem
upload_retries = 3
#time to wait between attempts to upload file if connection problem (in seconds)
upload_wait = 60

View File

@ -1,215 +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());
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_DIR_BINARIES = "/usr/lib/airtime";
const CONF_DIR_STORAGE = "/srv/airtime";
const CONF_DIR_WWW = "/var/www/airtime";
const CONF_DIR_LOG = "/var/log/airtime";
global $CC_CONFIG;
$configFiles = array(CONF_FILE_AIRTIME,
CONF_FILE_PYPO,
CONF_FILE_RECORDER,
CONF_FILE_LIQUIDSOAP);
$CC_CONFIG = array(
// prefix for table names in the database
'tblNamePrefix' => 'cc_',
/* ================================================ storage configuration */
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
"rootDir" => __DIR__."/../.."
);
$CC_CONFIG = LoadConfig($CC_CONFIG);
// Add database table names
$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';
$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents';
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule';
$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days';
$CC_CONFIG['showTable'] = $CC_CONFIG['tblNamePrefix'].'show';
$CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances';
$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
function LoadConfig($CC_CONFIG) {
$values = parse_ini_file(CONF_FILE_AIRTIME, true);
// Name of the web server user
$CC_CONFIG['webServerUser'] = $values['general']['web_server_user'];
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
$CC_CONFIG['rabbitmq'] = $values['rabbitmq'];
$CC_CONFIG['baseFilesDir'] = $values['general']['base_files_dir'];
// main directory for storing binary media files
$CC_CONFIG['storageDir'] = $values['general']['base_files_dir']."/stor";
//$CC_CONFIG['baseUrl'] = $values['general']['base_url'];
//$CC_CONFIG['basePort'] = $values['general']['base_port'];
// 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_CONFIG['apiKey'] = array($values['general']['api_key']);
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
return $CC_CONFIG;
}
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
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", CONF_FILE_AIRTIME)){
echo "Could not copy airtime.conf.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/pypo.cfg.$suffix", CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/recorder.cfg.$suffix", CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/liquidsoap.cfg.$suffix", CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
}
function ReadPythonConfig($p_filename)
{
$values = array();
$lines = file($p_filename);
$n=count($lines);
for ($i=0; $i<$n; $i++) {
if (strlen($lines[$i]) && !in_array(substr($lines[$i], 0, 1), array('#', PHP_EOL))){
$info = explode("=", $lines[$i]);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n=count($lines);
foreach ($lines as &$line) {
if ($line[0] != "#"){
$key_value = split("=", $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);
}
function MergeConfigFiles($configFiles, $suffix)
{
foreach ($configFiles as $conf) {
if (file_exists("$conf$suffix.bak")) {
if($conf === CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
}
else {
$newSettings = ReadPythonConfig($conf);
$oldSettings = 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) {
if(isset($oldSettings[$section][$sectionKey])) {
UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
}
}
}
else {
UpdateIniValue($conf, $section, $oldSettings[$section]);
}
}
}
}
}
}
// Backup the config files
$suffix = date("Ymdhis")."-1.8.1";
foreach ($configFiles as $conf) {
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
exec("cp $conf $conf$suffix.bak");
}
}
$default_suffix = "181";
CreateIniFiles($default_suffix);
echo "* Initializing INI files".PHP_EOL;
MergeConfigFiles($configFiles, $suffix);
$CC_CONFIG = LoadConfig($CC_CONFIG);

View File

@ -1,22 +0,0 @@
[database]
host = localhost
dbname = airtime
dbuser = airtime
dbpass = airtime
[rabbitmq]
host = 127.0.0.1
port = 5672
user = guest
password = guest
vhost = /
[general]
api_key = AAA
web_server_user = www-data
airtime_dir = x
base_files_dir = x
[soundcloud]
connection_retries = 3
time_between_retries = 60

View File

@ -1,38 +0,0 @@
###########################################
# liquidsoap config file #
###########################################
###########################################
# general settings #
###########################################
log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"
log_level = 3
###########################################
# stream settings #
###########################################
icecast_host = "127.0.0.1"
icecast_port = 8000
icecast_pass = "hackme"
###########################################
# webstream mountpoint names #
###########################################
mount_point_mp3 = "airtime.mp3"
mount_point_vorbis = "airtime.ogg"
###########################################
# webstream metadata settings #
###########################################
icecast_url = "http://airtime.sourcefabric.org"
icecast_description = "Airtime Radio!"
icecast_genre = "genre"
###########################################
#liquidsoap output settings #
###########################################
output_sound_device = false
output_icecast_vorbis = true
output_icecast_mp3 = false

View File

@ -1,112 +0,0 @@
############################################
# pypo - configuration #
############################################
# Set the type of client you are using.
# Currently supported types:
# 1) "obp" = Open Broadcast Platform
# 2) "airtime"
#
api_client = "airtime"
############################################
# Cache Directories #
# *include* trailing slash !! #
############################################
cache_dir = '/var/tmp/airtime/pypo/cache/'
file_dir = '/var/tmp/airtime/pypo/files/'
tmp_dir = '/var/tmp/airtime/pypo/tmp/'
############################################
# Setup Directories #
# Do *not* include trailing slash !! #
############################################
cache_base_dir = '/var/tmp/airtime/pypo'
bin_dir = '/usr/lib/airtime/pypo'
log_base_dir = '/var/log/airtime'
pypo_log_dir = '/var/log/airtime/pypo'
liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap'
# Hostname
base_url = 'localhost'
base_port = 80
############################################
# Liquidsoap settings #
############################################
ls_host = '127.0.0.1'
ls_port = '1234'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
############################################
# pypo preferences #
############################################
prepare_ahead = 24 #in hours
cache_for = 24 #how long to hold the cache, in hours
# Poll interval in seconds.
#
# This will rarely need to be changed because any schedule changes are
# automatically sent to pypo immediately.
#
# This is how often the poll script downloads new schedules and files from the
# server in the event that no changes are made to the schedule.
#
poll_interval = 3600 # in seconds.
# Push interval in seconds.
#
# This is how often the push script checks whether it has something new to
# push to liquidsoap.
#
# It's hard to imagine a situation where this should be more than 1 second.
#
push_interval = 1 # in seconds
# 'pre' or 'otf'. 'pre' cues while playlist preparation
# while 'otf' (on the fly) cues while loading into ls
# (needs the post_processor patch)
cue_style = 'pre'
################################################################################
# Uncomment *one of the sets* of values from the API clients below, and comment
# out all the others.
################################################################################
#####################
# Airtime Config #
#####################
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
# Schedule export path.
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
export_url = 'schedule/api_key/%%api_key%%'
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
# Update whether a schedule group has begun playing.
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
# Update whether an audio clip is currently playing.
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
# ???
generate_range_url = 'generate_range_dp.php'

View File

@ -1,35 +0,0 @@
api_client = "airtime"
# Hostname
base_url = 'localhost'
base_port = 80
# where the binary files live
bin_dir = '/usr/lib/airtime/show-recorder'
# base path to store recordered shows at
base_recorded_files = '/var/tmp/airtime/show-recorder/'
# where the logging files live
log_dir = '/var/log/airtime/show-recorder'
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
# URL to get the schedule of shows set to record
show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
# URL to upload the recorded show's file to Airtime
upload_file_url = 'upload-recorded/format/json/api_key/%%api_key%%'
#number of retries to upload file if connection problem
upload_retries = 3
#time to wait between attempts to upload file if connection problem (in seconds)
upload_wait = 60

View File

@ -1,216 +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());
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_DIR_BINARIES = "/usr/lib/airtime";
const CONF_DIR_STORAGE = "/srv/airtime";
const CONF_DIR_WWW = "/var/www/airtime";
const CONF_DIR_LOG = "/var/log/airtime";
global $CC_CONFIG;
$configFiles = array(CONF_FILE_AIRTIME,
CONF_FILE_PYPO,
CONF_FILE_RECORDER,
CONF_FILE_LIQUIDSOAP);
$CC_CONFIG = array(
// prefix for table names in the database
'tblNamePrefix' => 'cc_',
/* ================================================ storage configuration */
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
"rootDir" => __DIR__."/../.."
);
$CC_CONFIG = LoadConfig($CC_CONFIG);
// Add database table names
$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';
$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents';
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule';
$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days';
$CC_CONFIG['showTable'] = $CC_CONFIG['tblNamePrefix'].'show';
$CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances';
$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
function LoadConfig($CC_CONFIG) {
$values = parse_ini_file(CONF_FILE_AIRTIME, true);
// Name of the web server user
$CC_CONFIG['webServerUser'] = $values['general']['web_server_user'];
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
$CC_CONFIG['rabbitmq'] = $values['rabbitmq'];
$CC_CONFIG['baseFilesDir'] = $values['general']['base_files_dir'];
// main directory for storing binary media files
$CC_CONFIG['storageDir'] = $values['general']['base_files_dir']."/stor";
//these next two entries are new for this release, will be undefined on first load.
$CC_CONFIG['baseUrl'] = isset($values['general']['base_url'])?$values['general']['base_url']:null;
$CC_CONFIG['basePort'] = isset($values['general']['base_port'])?$values['general']['base_port']: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'];
$CC_CONFIG['apiKey'] = array($values['general']['api_key']);
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
return $CC_CONFIG;
}
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
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", CONF_FILE_AIRTIME)){
echo "Could not copy airtime.conf.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/pypo.cfg.$suffix", CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/recorder.cfg.$suffix", CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/liquidsoap.cfg.$suffix", CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg.$suffix to /etc/airtime/. Exiting.";
exit(1);
}
}
function ReadPythonConfig($p_filename)
{
$values = array();
$lines = file($p_filename);
$n=count($lines);
for ($i=0; $i<$n; $i++) {
if (strlen($lines[$i]) && !in_array(substr($lines[$i], 0, 1), array('#', PHP_EOL))){
$info = explode("=", $lines[$i]);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n=count($lines);
foreach ($lines as &$line) {
if ($line[0] != "#"){
$key_value = split("=", $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);
}
function MergeConfigFiles($configFiles, $suffix)
{
foreach ($configFiles as $conf) {
if (file_exists("$conf$suffix.bak")) {
if($conf === CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
}
else {
$newSettings = ReadPythonConfig($conf);
$oldSettings = 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) {
if(isset($oldSettings[$section][$sectionKey])) {
UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
}
}
}
else {
UpdateIniValue($conf, $section, $oldSettings[$section]);
}
}
}
}
}
}
$suffix = date("Ymdhis")."-1.8.2";
foreach ($configFiles as $conf) {
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
exec("cp $conf $conf$suffix.bak");
}
}
$default_suffix = "182";
CreateIniFiles($default_suffix);
echo "* Initializing INI files".PHP_EOL;
MergeConfigFiles($configFiles, $suffix);
$CC_CONFIG = LoadConfig($CC_CONFIG);

View File

@ -1,24 +0,0 @@
[database]
host = localhost
dbname = airtime
dbuser = airtime
dbpass = airtime
[rabbitmq]
host = 127.0.0.1
port = 5672
user = guest
password = guest
vhost = /
[general]
api_key = AAA
web_server_user = www-data
airtime_dir = x
base_files_dir = x
base_url = localhost
base_port = 80
[soundcloud]
connection_retries = 3
time_between_retries = 60

View File

@ -1,46 +0,0 @@
###########################################
# liquidsoap config file #
###########################################
###########################################
# general settings #
###########################################
log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"
log_level = 3
###########################################
# stream settings #
###########################################
icecast_host = "127.0.0.1"
icecast_port = 8000
icecast_pass = "hackme"
###########################################
# webstream mountpoint names #
###########################################
mount_point_mp3 = "airtime.mp3"
mount_point_vorbis = "airtime.ogg"
###########################################
# webstream metadata settings #
###########################################
icecast_url = "http://airtime.sourcefabric.org"
icecast_description = "Airtime Radio!"
icecast_genre = "genre"
###########################################
#liquidsoap output settings #
###########################################
output_sound_device = false
output_icecast_vorbis = true
output_icecast_mp3 = false
#audio stream metadata for vorbis/ogg is disabled by default
#due to a large number of client media players that disconnect
#when the metadata changes to that of a new track. Some versions of
#mplayer and VLC have this problem. Enable this option at your
#own risk!
output_icecast_vorbis_metadata = false

View File

@ -1,112 +0,0 @@
############################################
# pypo - configuration #
############################################
# Set the type of client you are using.
# Currently supported types:
# 1) "obp" = Open Broadcast Platform
# 2) "airtime"
#
api_client = "airtime"
############################################
# Cache Directories #
# *include* trailing slash !! #
############################################
cache_dir = '/var/tmp/airtime/pypo/cache/'
file_dir = '/var/tmp/airtime/pypo/files/'
tmp_dir = '/var/tmp/airtime/pypo/tmp/'
############################################
# Setup Directories #
# Do *not* include trailing slash !! #
############################################
cache_base_dir = '/var/tmp/airtime/pypo'
bin_dir = '/usr/lib/airtime/pypo'
log_base_dir = '/var/log/airtime'
pypo_log_dir = '/var/log/airtime/pypo'
liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap'
# Hostname
base_url = 'localhost'
base_port = 80
############################################
# Liquidsoap settings #
############################################
ls_host = '127.0.0.1'
ls_port = '1234'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
############################################
# pypo preferences #
############################################
prepare_ahead = 24 #in hours
cache_for = 24 #how long to hold the cache, in hours
# Poll interval in seconds.
#
# This will rarely need to be changed because any schedule changes are
# automatically sent to pypo immediately.
#
# This is how often the poll script downloads new schedules and files from the
# server in the event that no changes are made to the schedule.
#
poll_interval = 3600 # in seconds.
# Push interval in seconds.
#
# This is how often the push script checks whether it has something new to
# push to liquidsoap.
#
# It's hard to imagine a situation where this should be more than 1 second.
#
push_interval = 1 # in seconds
# 'pre' or 'otf'. 'pre' cues while playlist preparation
# while 'otf' (on the fly) cues while loading into ls
# (needs the post_processor patch)
cue_style = 'pre'
################################################################################
# Uncomment *one of the sets* of values from the API clients below, and comment
# out all the others.
################################################################################
#####################
# Airtime Config #
#####################
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
# Schedule export path.
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
export_url = 'schedule/api_key/%%api_key%%'
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
# Update whether a schedule group has begun playing.
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
# Update whether an audio clip is currently playing.
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
# ???
generate_range_url = 'generate_range_dp.php'

View File

@ -1,35 +0,0 @@
api_client = "airtime"
# Hostname
base_url = 'localhost'
base_port = 80
# where the binary files live
bin_dir = '/usr/lib/airtime/show-recorder'
# base path to store recordered shows at
base_recorded_files = '/var/tmp/airtime/show-recorder/'
# where the logging files live
log_dir = '/var/log/airtime/show-recorder'
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
# URL to get the schedule of shows set to record
show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
# URL to upload the recorded show's file to Airtime
upload_file_url = 'upload-recorded/format/json/api_key/%%api_key%%'
#number of retries to upload file if connection problem
upload_retries = 3
#time to wait between attempts to upload file if connection problem (in seconds)
upload_wait = 60

View File

@ -1,23 +0,0 @@
set daemon 10 # Poll at 10 second intervals
set logfile syslog facility log_daemon
set httpd port 2812 and use address 127.0.0.1
allow localhost
allow admin:monit
check process airtime-playout
with pidfile "/var/run/airtime-playout.pid"
start program = "/etc/init.d/airtime-playout start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-playout stop"
check process airtime-liquidsoap
with pidfile "/var/run/airtime-liquidsoap.pid"
start program = "/etc/init.d/airtime-playout start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-playout stop"
check process airtime-media-monitor
with pidfile "/var/run/airtime-media-monitor.pid"
start program = "/etc/init.d/airtime-media-monitor start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-media-monitor stop"
check process airtime-show-recorder
with pidfile "/var/run/airtime-show-recorder.pid"
start program = "/etc/init.d/airtime-show-recorder start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-show-recorder stop"

View File

@ -1,844 +0,0 @@
<?php
set_include_path(__DIR__.'/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
require_once 'conf.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");
date_default_timezone_set(exec("cat /etc/timezone"));
const CONF_DIR_BINARIES = "/usr/lib/airtime";
class AirtimeInstall{
const CONF_DIR_LOG = "/var/log/airtime";
const CONF_DIR_BINARIES = "/usr/lib/airtime";
public static function CreateZendPhpLogFile(){
global $CC_CONFIG;
echo "* Creating logs directory ".AirtimeInstall::CONF_DIR_LOG.PHP_EOL;
$path = AirtimeInstall::CONF_DIR_LOG;
$file = $path.'/zendphp.log';
if (!file_exists($path)){
mkdir($path, 0755, true);
}
touch($file);
chmod($file, 0755);
chown($file, $CC_CONFIG['webServerUser']);
chgrp($file, $CC_CONFIG['webServerUser']);
}
public static function CreateSymlinksToUtils()
{
echo "* Creating /usr/bin symlinks".PHP_EOL;
AirtimeInstall::RemoveSymlinks();
echo "* Installing airtime-import".PHP_EOL;
$dir = CONF_DIR_BINARIES."/utils/airtime-import/airtime-import";
exec("ln -s $dir /usr/bin/airtime-import");
echo "* Installing airtime-update-db-settings".PHP_EOL;
$dir = CONF_DIR_BINARIES."/utils/airtime-update-db-settings";
exec("ln -s $dir /usr/bin/airtime-update-db-settings");
echo "* Installing airtime-check-system".PHP_EOL;
$dir = CONF_DIR_BINARIES."/utils/airtime-check-system";
exec("ln -s $dir /usr/bin/airtime-check-system");
echo "* Installing airtime-user".PHP_EOL;
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-user";
exec("ln -s $dir /usr/bin/airtime-user");
}
public static function RemoveSymlinks()
{
exec("rm -f /usr/bin/airtime-import");
exec("rm -f /usr/bin/airtime-update-db-settings");
exec("rm -f /usr/bin/airtime-check-system");
exec("rm -f /usr/bin/airtime-user");
exec("rm -f /usr/bin/airtime-clean-storage ");
}
public static function DbTableExists($p_name)
{
$con = Propel::getConnection();
try {
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
$con->query($sql);
} catch (PDOException $e){
return false;
}
return true;
}
public static function BypassMigrations($dir, $version)
{
$appDir = AirtimeInstall::GetAirtimeSrcDir();
$SCRIPTPATH = __DIR__;
$command = "php --php-ini $SCRIPTPATH/../../airtime-php.ini ".
"$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";
passthru($command);
}
public static function MigrateTablesToVersion($dir, $version)
{
echo "Upgrading database, may take several minutes, please wait".PHP_EOL;
$appDir = AirtimeInstall::GetAirtimeSrcDir();
$SCRIPTPATH = __DIR__;
$command = "php --php-ini $SCRIPTPATH/../../airtime-php.ini ".
"$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";
passthru($command);
}
public static function CreateCronFile(){
// Create CRON task to run every day. Time of day is initialized to a random time.
$hour = rand(0,23);
$minute = rand(0,59);
$fp = fopen('/etc/cron.d/airtime-crons','w');
fwrite($fp, "$minute $hour * * * root /usr/lib/airtime/utils/phone_home_stat\n");
fclose($fp);
}
public static function GetAirtimeSrcDir()
{
return __DIR__."/../../../airtime_mvc";
}
public static function InsertCountryDataIntoDatabase(){
$sql = "INSERT INTO cc_country (isocode, name) VALUES ('AFG', 'Afghanistan ');
INSERT INTO cc_country (isocode, name) VALUES ('ALA', 'Åland Islands');
INSERT INTO cc_country (isocode, name) VALUES ('ALB', 'Albania ');
INSERT INTO cc_country (isocode, name) VALUES ('DZA', 'Algeria ');
INSERT INTO cc_country (isocode, name) VALUES ('ASM', 'American Samoa ');
INSERT INTO cc_country (isocode, name) VALUES ('AND', 'Andorra ');
INSERT INTO cc_country (isocode, name) VALUES ('AGO', 'Angola ');
INSERT INTO cc_country (isocode, name) VALUES ('AIA', 'Anguilla ');
INSERT INTO cc_country (isocode, name) VALUES ('ATG', 'Antigua and Barbuda ');
INSERT INTO cc_country (isocode, name) VALUES ('ARG', 'Argentina ');
INSERT INTO cc_country (isocode, name) VALUES ('ARM', 'Armenia ');
INSERT INTO cc_country (isocode, name) VALUES ('ABW', 'Aruba ');
INSERT INTO cc_country (isocode, name) VALUES ('AUS', 'Australia ');
INSERT INTO cc_country (isocode, name) VALUES ('AUT', 'Austria ');
INSERT INTO cc_country (isocode, name) VALUES ('AZE', 'Azerbaijan ');
INSERT INTO cc_country (isocode, name) VALUES ('BHS', 'Bahamas ');
INSERT INTO cc_country (isocode, name) VALUES ('BHR', 'Bahrain ');
INSERT INTO cc_country (isocode, name) VALUES ('BGD', 'Bangladesh ');
INSERT INTO cc_country (isocode, name) VALUES ('BRB', 'Barbados ');
INSERT INTO cc_country (isocode, name) VALUES ('BLR', 'Belarus ');
INSERT INTO cc_country (isocode, name) VALUES ('BEL', 'Belgium ');
INSERT INTO cc_country (isocode, name) VALUES ('BLZ', 'Belize ');
INSERT INTO cc_country (isocode, name) VALUES ('BEN', 'Benin ');
INSERT INTO cc_country (isocode, name) VALUES ('BMU', 'Bermuda ');
INSERT INTO cc_country (isocode, name) VALUES ('BTN', 'Bhutan ');
INSERT INTO cc_country (isocode, name) VALUES ('BOL', 'Bolivia (Plurinational State of) ');
INSERT INTO cc_country (isocode, name) VALUES ('BES', 'Bonaire, Saint Eustatius and Saba');
INSERT INTO cc_country (isocode, name) VALUES ('BIH', 'Bosnia and Herzegovina ');
INSERT INTO cc_country (isocode, name) VALUES ('BWA', 'Botswana ');
INSERT INTO cc_country (isocode, name) VALUES ('BRA', 'Brazil ');
INSERT INTO cc_country (isocode, name) VALUES ('VGB', 'British Virgin Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('BRN', 'Brunei Darussalam ');
INSERT INTO cc_country (isocode, name) VALUES ('BGR', 'Bulgaria ');
INSERT INTO cc_country (isocode, name) VALUES ('BFA', 'Burkina Faso ');
INSERT INTO cc_country (isocode, name) VALUES ('BDI', 'Burundi ');
INSERT INTO cc_country (isocode, name) VALUES ('KHM', 'Cambodia ');
INSERT INTO cc_country (isocode, name) VALUES ('CMR', 'Cameroon ');
INSERT INTO cc_country (isocode, name) VALUES ('CAN', 'Canada ');
INSERT INTO cc_country (isocode, name) VALUES ('CPV', 'Cape Verde ');
INSERT INTO cc_country (isocode, name) VALUES ('CYM', 'Cayman Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('CAF', 'Central African Republic ');
INSERT INTO cc_country (isocode, name) VALUES ('TCD', 'Chad ');
INSERT INTO cc_country (isocode, name) VALUES ('CHL', 'Chile ');
INSERT INTO cc_country (isocode, name) VALUES ('CHN', 'China ');
INSERT INTO cc_country (isocode, name) VALUES ('HKG', 'China, Hong Kong Special Administrative Region');
INSERT INTO cc_country (isocode, name) VALUES ('MAC', 'China, Macao Special Administrative Region');
INSERT INTO cc_country (isocode, name) VALUES ('COL', 'Colombia ');
INSERT INTO cc_country (isocode, name) VALUES ('COM', 'Comoros ');
INSERT INTO cc_country (isocode, name) VALUES ('COG', 'Congo ');
INSERT INTO cc_country (isocode, name) VALUES ('COK', 'Cook Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('CRI', 'Costa Rica ');
INSERT INTO cc_country (isocode, name) VALUES ('CIV', 'Côte d''Ivoire ');
INSERT INTO cc_country (isocode, name) VALUES ('HRV', 'Croatia ');
INSERT INTO cc_country (isocode, name) VALUES ('CUB', 'Cuba ');
INSERT INTO cc_country (isocode, name) VALUES ('CUW', 'Curaçao');
INSERT INTO cc_country (isocode, name) VALUES ('CYP', 'Cyprus ');
INSERT INTO cc_country (isocode, name) VALUES ('CZE', 'Czech Republic ');
INSERT INTO cc_country (isocode, name) VALUES ('PRK', 'Democratic People''s Republic of Korea ');
INSERT INTO cc_country (isocode, name) VALUES ('COD', 'Democratic Republic of the Congo ');
INSERT INTO cc_country (isocode, name) VALUES ('DNK', 'Denmark ');
INSERT INTO cc_country (isocode, name) VALUES ('DJI', 'Djibouti ');
INSERT INTO cc_country (isocode, name) VALUES ('DMA', 'Dominica ');
INSERT INTO cc_country (isocode, name) VALUES ('DOM', 'Dominican Republic ');
INSERT INTO cc_country (isocode, name) VALUES ('ECU', 'Ecuador ');
INSERT INTO cc_country (isocode, name) VALUES ('EGY', 'Egypt ');
INSERT INTO cc_country (isocode, name) VALUES ('SLV', 'El Salvador ');
INSERT INTO cc_country (isocode, name) VALUES ('GNQ', 'Equatorial Guinea ');
INSERT INTO cc_country (isocode, name) VALUES ('ERI', 'Eritrea ');
INSERT INTO cc_country (isocode, name) VALUES ('EST', 'Estonia ');
INSERT INTO cc_country (isocode, name) VALUES ('ETH', 'Ethiopia ');
INSERT INTO cc_country (isocode, name) VALUES ('FRO', 'Faeroe Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('FLK', 'Falkland Islands (Malvinas) ');
INSERT INTO cc_country (isocode, name) VALUES ('FJI', 'Fiji ');
INSERT INTO cc_country (isocode, name) VALUES ('FIN', 'Finland ');
INSERT INTO cc_country (isocode, name) VALUES ('FRA', 'France ');
INSERT INTO cc_country (isocode, name) VALUES ('GUF', 'French Guiana ');
INSERT INTO cc_country (isocode, name) VALUES ('PYF', 'French Polynesia ');
INSERT INTO cc_country (isocode, name) VALUES ('GAB', 'Gabon ');
INSERT INTO cc_country (isocode, name) VALUES ('GMB', 'Gambia ');
INSERT INTO cc_country (isocode, name) VALUES ('GEO', 'Georgia ');
INSERT INTO cc_country (isocode, name) VALUES ('DEU', 'Germany ');
INSERT INTO cc_country (isocode, name) VALUES ('GHA', 'Ghana ');
INSERT INTO cc_country (isocode, name) VALUES ('GIB', 'Gibraltar ');
INSERT INTO cc_country (isocode, name) VALUES ('GRC', 'Greece ');
INSERT INTO cc_country (isocode, name) VALUES ('GRL', 'Greenland ');
INSERT INTO cc_country (isocode, name) VALUES ('GRD', 'Grenada ');
INSERT INTO cc_country (isocode, name) VALUES ('GLP', 'Guadeloupe ');
INSERT INTO cc_country (isocode, name) VALUES ('GUM', 'Guam ');
INSERT INTO cc_country (isocode, name) VALUES ('GTM', 'Guatemala ');
INSERT INTO cc_country (isocode, name) VALUES ('GGY', 'Guernsey');
INSERT INTO cc_country (isocode, name) VALUES ('GIN', 'Guinea ');
INSERT INTO cc_country (isocode, name) VALUES ('GNB', 'Guinea-Bissau ');
INSERT INTO cc_country (isocode, name) VALUES ('GUY', 'Guyana ');
INSERT INTO cc_country (isocode, name) VALUES ('HTI', 'Haiti ');
INSERT INTO cc_country (isocode, name) VALUES ('VAT', 'Holy See ');
INSERT INTO cc_country (isocode, name) VALUES ('HND', 'Honduras ');
INSERT INTO cc_country (isocode, name) VALUES ('HUN', 'Hungary ');
INSERT INTO cc_country (isocode, name) VALUES ('ISL', 'Iceland ');
INSERT INTO cc_country (isocode, name) VALUES ('IND', 'India ');
INSERT INTO cc_country (isocode, name) VALUES ('IDN', 'Indonesia ');
INSERT INTO cc_country (isocode, name) VALUES ('IRN', 'Iran (Islamic Republic of)');
INSERT INTO cc_country (isocode, name) VALUES ('IRQ', 'Iraq ');
INSERT INTO cc_country (isocode, name) VALUES ('IRL', 'Ireland ');
INSERT INTO cc_country (isocode, name) VALUES ('IMN', 'Isle of Man ');
INSERT INTO cc_country (isocode, name) VALUES ('ISR', 'Israel ');
INSERT INTO cc_country (isocode, name) VALUES ('ITA', 'Italy ');
INSERT INTO cc_country (isocode, name) VALUES ('JAM', 'Jamaica ');
INSERT INTO cc_country (isocode, name) VALUES ('JPN', 'Japan ');
INSERT INTO cc_country (isocode, name) VALUES ('JEY', 'Jersey');
INSERT INTO cc_country (isocode, name) VALUES ('JOR', 'Jordan ');
INSERT INTO cc_country (isocode, name) VALUES ('KAZ', 'Kazakhstan ');
INSERT INTO cc_country (isocode, name) VALUES ('KEN', 'Kenya ');
INSERT INTO cc_country (isocode, name) VALUES ('KIR', 'Kiribati ');
INSERT INTO cc_country (isocode, name) VALUES ('KWT', 'Kuwait ');
INSERT INTO cc_country (isocode, name) VALUES ('KGZ', 'Kyrgyzstan ');
INSERT INTO cc_country (isocode, name) VALUES ('LAO', 'Lao People''s Democratic Republic ');
INSERT INTO cc_country (isocode, name) VALUES ('LVA', 'Latvia ');
INSERT INTO cc_country (isocode, name) VALUES ('LBN', 'Lebanon ');
INSERT INTO cc_country (isocode, name) VALUES ('LSO', 'Lesotho ');
INSERT INTO cc_country (isocode, name) VALUES ('LBR', 'Liberia ');
INSERT INTO cc_country (isocode, name) VALUES ('LBY', 'Libyan Arab Jamahiriya ');
INSERT INTO cc_country (isocode, name) VALUES ('LIE', 'Liechtenstein ');
INSERT INTO cc_country (isocode, name) VALUES ('LTU', 'Lithuania ');
INSERT INTO cc_country (isocode, name) VALUES ('LUX', 'Luxembourg ');
INSERT INTO cc_country (isocode, name) VALUES ('MDG', 'Madagascar ');
INSERT INTO cc_country (isocode, name) VALUES ('MWI', 'Malawi ');
INSERT INTO cc_country (isocode, name) VALUES ('MYS', 'Malaysia ');
INSERT INTO cc_country (isocode, name) VALUES ('MDV', 'Maldives ');
INSERT INTO cc_country (isocode, name) VALUES ('MLI', 'Mali ');
INSERT INTO cc_country (isocode, name) VALUES ('MLT', 'Malta ');
INSERT INTO cc_country (isocode, name) VALUES ('MHL', 'Marshall Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('MTQ', 'Martinique ');
INSERT INTO cc_country (isocode, name) VALUES ('MRT', 'Mauritania ');
INSERT INTO cc_country (isocode, name) VALUES ('MUS', 'Mauritius ');
INSERT INTO cc_country (isocode, name) VALUES ('MYT', 'Mayotte');
INSERT INTO cc_country (isocode, name) VALUES ('MEX', 'Mexico ');
INSERT INTO cc_country (isocode, name) VALUES ('FSM', 'Micronesia (Federated States of)');
INSERT INTO cc_country (isocode, name) VALUES ('MCO', 'Monaco ');
INSERT INTO cc_country (isocode, name) VALUES ('MNG', 'Mongolia ');
INSERT INTO cc_country (isocode, name) VALUES ('MNE', 'Montenegro');
INSERT INTO cc_country (isocode, name) VALUES ('MSR', 'Montserrat ');
INSERT INTO cc_country (isocode, name) VALUES ('MAR', 'Morocco ');
INSERT INTO cc_country (isocode, name) VALUES ('MOZ', 'Mozambique ');
INSERT INTO cc_country (isocode, name) VALUES ('MMR', 'Myanmar ');
INSERT INTO cc_country (isocode, name) VALUES ('NAM', 'Namibia ');
INSERT INTO cc_country (isocode, name) VALUES ('NRU', 'Nauru ');
INSERT INTO cc_country (isocode, name) VALUES ('NPL', 'Nepal ');
INSERT INTO cc_country (isocode, name) VALUES ('NLD', 'Netherlands ');
INSERT INTO cc_country (isocode, name) VALUES ('NCL', 'New Caledonia ');
INSERT INTO cc_country (isocode, name) VALUES ('NZL', 'New Zealand ');
INSERT INTO cc_country (isocode, name) VALUES ('NIC', 'Nicaragua ');
INSERT INTO cc_country (isocode, name) VALUES ('NER', 'Niger ');
INSERT INTO cc_country (isocode, name) VALUES ('NGA', 'Nigeria ');
INSERT INTO cc_country (isocode, name) VALUES ('NIU', 'Niue ');
INSERT INTO cc_country (isocode, name) VALUES ('NFK', 'Norfolk Island ');
INSERT INTO cc_country (isocode, name) VALUES ('MNP', 'Northern Mariana Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('NOR', 'Norway ');
INSERT INTO cc_country (isocode, name) VALUES ('PSE', 'Occupied Palestinian Territory ');
INSERT INTO cc_country (isocode, name) VALUES ('OMN', 'Oman ');
INSERT INTO cc_country (isocode, name) VALUES ('PAK', 'Pakistan ');
INSERT INTO cc_country (isocode, name) VALUES ('PLW', 'Palau ');
INSERT INTO cc_country (isocode, name) VALUES ('PAN', 'Panama ');
INSERT INTO cc_country (isocode, name) VALUES ('PNG', 'Papua New Guinea ');
INSERT INTO cc_country (isocode, name) VALUES ('PRY', 'Paraguay ');
INSERT INTO cc_country (isocode, name) VALUES ('PER', 'Peru ');
INSERT INTO cc_country (isocode, name) VALUES ('PHL', 'Philippines ');
INSERT INTO cc_country (isocode, name) VALUES ('PCN', 'Pitcairn ');
INSERT INTO cc_country (isocode, name) VALUES ('POL', 'Poland ');
INSERT INTO cc_country (isocode, name) VALUES ('PRT', 'Portugal ');
INSERT INTO cc_country (isocode, name) VALUES ('PRI', 'Puerto Rico ');
INSERT INTO cc_country (isocode, name) VALUES ('QAT', 'Qatar ');
INSERT INTO cc_country (isocode, name) VALUES ('KOR', 'Republic of Korea ');
INSERT INTO cc_country (isocode, name) VALUES ('MDA', 'Republic of Moldova');
INSERT INTO cc_country (isocode, name) VALUES ('REU', 'Réunion ');
INSERT INTO cc_country (isocode, name) VALUES ('ROU', 'Romania ');
INSERT INTO cc_country (isocode, name) VALUES ('RUS', 'Russian Federation ');
INSERT INTO cc_country (isocode, name) VALUES ('RWA', 'Rwanda ');
INSERT INTO cc_country (isocode, name) VALUES ('BLM', 'Saint-Barthélemy');
INSERT INTO cc_country (isocode, name) VALUES ('SHN', 'Saint Helena ');
INSERT INTO cc_country (isocode, name) VALUES ('KNA', 'Saint Kitts and Nevis ');
INSERT INTO cc_country (isocode, name) VALUES ('LCA', 'Saint Lucia ');
INSERT INTO cc_country (isocode, name) VALUES ('MAF', 'Saint-Martin (French part)');
INSERT INTO cc_country (isocode, name) VALUES ('SPM', 'Saint Pierre and Miquelon ');
INSERT INTO cc_country (isocode, name) VALUES ('VCT', 'Saint Vincent and the Grenadines ');
INSERT INTO cc_country (isocode, name) VALUES ('WSM', 'Samoa ');
INSERT INTO cc_country (isocode, name) VALUES ('SMR', 'San Marino ');
INSERT INTO cc_country (isocode, name) VALUES ('STP', 'Sao Tome and Principe ');
INSERT INTO cc_country (isocode, name) VALUES ('SAU', 'Saudi Arabia ');
INSERT INTO cc_country (isocode, name) VALUES ('SEN', 'Senegal ');
INSERT INTO cc_country (isocode, name) VALUES ('SRB', 'Serbia ');
INSERT INTO cc_country (isocode, name) VALUES ('SYC', 'Seychelles ');
INSERT INTO cc_country (isocode, name) VALUES ('SLE', 'Sierra Leone ');
INSERT INTO cc_country (isocode, name) VALUES ('SGP', 'Singapore ');
INSERT INTO cc_country (isocode, name) VALUES ('SXM', 'Sint Maarten (Dutch part)');
INSERT INTO cc_country (isocode, name) VALUES ('SVK', 'Slovakia ');
INSERT INTO cc_country (isocode, name) VALUES ('SVN', 'Slovenia ');
INSERT INTO cc_country (isocode, name) VALUES ('SLB', 'Solomon Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('SOM', 'Somalia ');
INSERT INTO cc_country (isocode, name) VALUES ('ZAF', 'South Africa ');
INSERT INTO cc_country (isocode, name) VALUES ('ESP', 'Spain ');
INSERT INTO cc_country (isocode, name) VALUES ('LKA', 'Sri Lanka ');
INSERT INTO cc_country (isocode, name) VALUES ('SDN', 'Sudan ');
INSERT INTO cc_country (isocode, name) VALUES ('SUR', 'Suriname ');
INSERT INTO cc_country (isocode, name) VALUES ('SJM', 'Svalbard and Jan Mayen Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('SWZ', 'Swaziland ');
INSERT INTO cc_country (isocode, name) VALUES ('SWE', 'Sweden ');
INSERT INTO cc_country (isocode, name) VALUES ('CHE', 'Switzerland ');
INSERT INTO cc_country (isocode, name) VALUES ('SYR', 'Syrian Arab Republic ');
INSERT INTO cc_country (isocode, name) VALUES ('TJK', 'Tajikistan ');
INSERT INTO cc_country (isocode, name) VALUES ('THA', 'Thailand ');
INSERT INTO cc_country (isocode, name) VALUES ('MKD', 'The former Yugoslav Republic of Macedonia ');
INSERT INTO cc_country (isocode, name) VALUES ('TLS', 'Timor-Leste');
INSERT INTO cc_country (isocode, name) VALUES ('TGO', 'Togo ');
INSERT INTO cc_country (isocode, name) VALUES ('TKL', 'Tokelau ');
INSERT INTO cc_country (isocode, name) VALUES ('TON', 'Tonga ');
INSERT INTO cc_country (isocode, name) VALUES ('TTO', 'Trinidad and Tobago ');
INSERT INTO cc_country (isocode, name) VALUES ('TUN', 'Tunisia ');
INSERT INTO cc_country (isocode, name) VALUES ('TUR', 'Turkey ');
INSERT INTO cc_country (isocode, name) VALUES ('TKM', 'Turkmenistan ');
INSERT INTO cc_country (isocode, name) VALUES ('TCA', 'Turks and Caicos Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('TUV', 'Tuvalu ');
INSERT INTO cc_country (isocode, name) VALUES ('UGA', 'Uganda ');
INSERT INTO cc_country (isocode, name) VALUES ('UKR', 'Ukraine ');
INSERT INTO cc_country (isocode, name) VALUES ('ARE', 'United Arab Emirates ');
INSERT INTO cc_country (isocode, name) VALUES ('GBR', 'United Kingdom of Great Britain and Northern Ireland');
INSERT INTO cc_country (isocode, name) VALUES ('TZA', 'United Republic of Tanzania ');
INSERT INTO cc_country (isocode, name) VALUES ('USA', 'United States of America');
INSERT INTO cc_country (isocode, name) VALUES ('VIR', 'United States Virgin Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('URY', 'Uruguay ');
INSERT INTO cc_country (isocode, name) VALUES ('UZB', 'Uzbekistan ');
INSERT INTO cc_country (isocode, name) VALUES ('VUT', 'Vanuatu ');
INSERT INTO cc_country (isocode, name) VALUES ('VEN', 'Venezuela (Bolivarian Republic of)');
INSERT INTO cc_country (isocode, name) VALUES ('VNM', 'Viet Nam ');
INSERT INTO cc_country (isocode, name) VALUES ('WLF', 'Wallis and Futuna Islands ');
INSERT INTO cc_country (isocode, name) VALUES ('ESH', 'Western Sahara ');
INSERT INTO cc_country (isocode, name) VALUES ('YEM', 'Yemen ');
INSERT INTO cc_country (isocode, name) VALUES ('ZMB', 'Zambia ');
INSERT INTO cc_country (isocode, name) VALUES ('ZWE', 'Zimbabwe ');";
echo "* Inserting data into country table".PHP_EOL;
Airtime190Upgrade::execSqlQuery($sql);
}
public static function SetUniqueId()
{
$con = Propel::getConnection();
$uniqueId = md5(uniqid("", true));
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')";
$result = $con->exec($sql);
if ($result < 1) {
return false;
}
return true;
}
public static function SetImportTimestamp()
{
$con = Propel::getConnection();
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')";
$result = $con->exec($sql);
if ($result < 1) {
return false;
}
return true;
}
}
class AirtimeIni{
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_FILE_MONIT = "/etc/monit/conf.d/airtime-monit.cfg";
/**
* 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 CreateMonitFile(){
if (!copy(__DIR__."/airtime-monit.cfg.190", AirtimeIni::CONF_FILE_MONIT)){
echo "Could not copy airtime-monit.cfg to /etc/monit/conf.d/. Exiting.";
exit(1);
}
}
public static function ReadPythonConfig($p_filename)
{
$values = array();
$lines = file($p_filename);
$n=count($lines);
for ($i=0; $i<$n; $i++) {
if (strlen($lines[$i]) && !in_array(substr($lines[$i], 0, 1), array('#', PHP_EOL))){
$info = explode("=", $lines[$i]);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
public static function MergeConfigFiles($configFiles, $suffix) {
foreach ($configFiles as $conf) {
if (file_exists("$conf$suffix.bak")) {
if($conf === AirtimeIni::CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
}
else {
$newSettings = AirtimeIni::ReadPythonConfig($conf);
$oldSettings = AirtimeIni::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) {
if(isset($oldSettings[$section][$sectionKey])) {
AirtimeIni::UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
}
}
}
else {
AirtimeIni::UpdateIniValue($conf, $section, $oldSettings[$section]);
}
}
}
}
}
}
public static function upgradeConfigFiles(){
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
AirtimeIni::CONF_FILE_PYPO,
AirtimeIni::CONF_FILE_RECORDER,
AirtimeIni::CONF_FILE_LIQUIDSOAP);
// Backup the config files
$suffix = date("Ymdhis")."-1.9.0";
foreach ($configFiles as $conf) {
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
copy($conf, $conf.$suffix.".bak");
}
}
$default_suffix = "190";
AirtimeIni::CreateIniFiles($default_suffix);
AirtimeIni::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", AirtimeIni::CONF_FILE_AIRTIME)){
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/pypo.cfg.$suffix", AirtimeIni::CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/recorder.cfg.$suffix", AirtimeIni::CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/liquidsoap.cfg.$suffix", AirtimeIni::CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
exit(1);
}
}
}
class Airtime190Upgrade{
public static function InstallAirtimePhpServerCode($phpDir)
{
// delete old files
exec("rm -rf ".$phpDir);
$AIRTIME_SRC = realpath(__DIR__.'/../../../airtime_mvc');
echo "* Installing PHP code to ".$phpDir.PHP_EOL;
exec("mkdir -p ".$phpDir);
exec("cp -R ".$AIRTIME_SRC."/* ".$phpDir);
}
public static function CopyUtils()
{
$utilsSrc = __DIR__."/../../../utils";
echo "* Installing binaries to ".CONF_DIR_BINARIES.PHP_EOL;
exec("mkdir -p ".CONF_DIR_BINARIES);
exec("cp -R ".$utilsSrc." ".CONF_DIR_BINARIES);
}
/* Removes pypo, media-monitor, show-recorder and utils from system. These will
* be reinstalled by the main airtime-upgrade script.
*/
public static function UninstallBinaries()
{
echo "* Removing Airtime binaries from ".CONF_DIR_BINARIES.PHP_EOL;
$command = "rm -rf $(ls -d /usr/lib/airtime/* | grep -v airtime_virtualenv)";
exec($command);
}
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 {$e->getMessage()}".PHP_EOL;
}
return $result;
}
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) {
echo "Save DbMd to File".PHP_EOL;
/* Do not use realpath. It expands a symlinked path into its real path
* which then causes us problems for string comparisons later on. */
//$stor_dir = realpath($values['general']['base_files_dir']."/stor");
$baseDir = $values['general']['base_files_dir'];
if ($baseDir[strlen($baseDir)-1] != '/'){
$baseDir.='/';
}
$stor_dir = $baseDir.'stor';
$files = CcFilesQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->find();
$dumpFile = __DIR__."/storDump.txt";
$fh = fopen($dumpFile, 'w') or die("can't open file to backup stor.");
$s = "SF_BACKUP_1.9.0";
foreach ($files as $file) {
$filepath = $file->getDbFilepath();
if (substr($filepath, 0, strlen($stor_dir)) == $stor_dir) {
$recorded_show = CcShowInstancesQuery::create()
->filterByDbRecordedFile($file->getDbId())
->findOne();
if (isset($recorded_show)) {
$start_time = $recorded_show->getDbStarts();
$title = $file->getDbTrackTitle();
$start_time = str_replace(" ", "-", $start_time);
$start_time = str_replace(":", "-", $start_time);
//$start_time like yyyy-mm-dd-hh-MM-ss
list($yyyy, $mm, $dd, $hh, $MM, $ss) = explode("-", $start_time);
$data = "1$s$filepath$s$title$s$yyyy$s$mm$s$dd$s$hh$s$MM\n";
}
else {
$artist = $file->getDbArtistName();
$album = $file->getDbAlbumTitle();
$track = $file->getDbTrackNumber();
$title = $file->getDbTrackTitle();
$data = "0$s$filepath$s$title$s$artist$s$album$s$track\n";
}
fwrite($fh, $data);
}
}
fclose($fh);
}
/* Old database had a "fullpath" column that stored the absolute path of each track. We have to
* change it so that the "fullpath" column has path relative to the "directory" column.
*/
public static function installMediaMonitor($values){
$propel_stor_dir = CcMusicDirsQuery::create()
->filterByType('stor')
->findOne();
$propel_link_dir = CcMusicDirsQuery::create()
->filterByType('link')
->findOne();
/* Handle Database Changes. */
$pi = pathinfo($values['general']['base_files_dir']);
$stor_dir = $pi["dirname"].DIRECTORY_SEPARATOR.$pi["basename"].DIRECTORY_SEPARATOR."stor".DIRECTORY_SEPARATOR;
echo "* Inserting stor directory location $stor_dir into music_dirs table".PHP_EOL;
$propel_stor_dir->setDirectory($stor_dir);
$propel_stor_dir->save();
echo "Creating media-monitor log file".PHP_EOL;
mkdir("/var/log/airtime/media-monitor/", 755, true);
touch("/var/log/airtime/media-monitor/media-monitor.log");
/* create media monitor config: */
if (!copy(__DIR__."/media-monitor.cfg.190", AirtimeIni::CONF_FILE_MEDIAMONITOR)){
echo "Could not copy media-monitor.cfg to /etc/airtime/. Exiting.";
}
if (!copy(__DIR__."/api_client.cfg.190", AirtimeIni::CONF_FILE_API_CLIENT)){
echo "Could not copy api_client.cfg to /etc/airtime/. Exiting.";
}
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_API_CLIENT, "api_key", $values["general"]["api_key"]);
echo "Reorganizing files in stor directory".PHP_EOL;
$cwd = __DIR__;
$mediaMonitorUpgradePath = __DIR__."/media-monitor-upgrade.py";
$command = "cd $cwd && python $mediaMonitorUpgradePath";
exec($command, $output);
print_r($output);
if (isset($output[0])) {
$oldAndNewFileNames = json_decode($output[0]);
$stor_dir_id = $propel_stor_dir->getId();
foreach ($oldAndNewFileNames as $pair){
$relPathNew = pg_escape_string(substr($pair[1], strlen($stor_dir)));
$absPathOld = pg_escape_string($pair[0]);
$sql = "UPDATE cc_files SET filepath = '$relPathNew', directory=$stor_dir_id WHERE filepath = '$absPathOld'";
echo $sql.PHP_EOL;
Airtime190Upgrade::execSqlQuery($sql);
}
}
echo "Upgrading Linked Files".PHP_EOL;
//HANDLE LINKED FILES HERE.
$db_files = CcFilesQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->filterByDbDirectory(NULL)
->find();
//Check to see if the file still exists. (Could have still some entries under the stor dir or linked files that don't exist)
$link_dir_id = $propel_link_dir->getId();
foreach($db_files as $db_file) {
$filepath = $db_file->getDbFilepath();
echo $filepath.PHP_EOL;
if (!file_exists($filepath)) {
$db_file->delete();
echo "Removed Missing File: ".$filepath.PHP_EOL;
}
else {
$db_file->setDbDirectory($link_dir_id);
$db_file->save();
}
}
}
}
AirtimeInstall::CreateZendPhpLogFile();
/* In version 1.9.0 we have have switched from daemontools to more traditional
* init.d daemon system. Let's remove all the daemontools files
*/
exec("/usr/bin/airtime-pypo-stop");
exec("/usr/bin/airtime-show-recorder-stop");
exec("svc -dx /etc/service/pypo");
exec("svc -dx /etc/service/pypo/log");
exec("svc -dx /etc/service/pypo-liquidsoap");
exec("svc -dx /etc/service/pypo-liquidsoap/log");
exec("svc -dx /etc/service/recorder");
exec("svc -dx /etc/service/recorder/log");
exec("killall supervise");
exec("killall liquidsoap");
$pathnames = array("/usr/bin/airtime-pypo-start",
"/usr/bin/airtime-pypo-stop",
"/usr/bin/airtime-show-recorder-start",
"/usr/bin/airtime-show-recorder-stop",
"/usr/bin/airtime-media-monitor-start",
"/usr/bin/airtime-media-monitor-stop",
"/etc/service/pypo",
"/etc/service/pypo-liquidsoap",
"/etc/service/media-monitor",
"/etc/service/recorder",
"/var/log/airtime/pypo/main",
"/var/log/airtime/pypo-liquidsoap/main",
"/var/log/airtime/show-recorder/main"
);
foreach ($pathnames as $pn){
echo "Removing $pn\n";
exec("rm -rf \"$pn\"");
}
/* update Airtime Server PHP files */
$values = parse_ini_file(AirtimeIni::CONF_FILE_AIRTIME, true);
$phpDir = $values['general']['airtime_dir'];
Airtime190Upgrade::InstallAirtimePhpServerCode($phpDir);
/* update utils (/usr/lib/airtime) folder */
Airtime190Upgrade::UninstallBinaries();
Airtime190Upgrade::CopyUtils();
/* James made a new airtime-import script, lets remove the old airtime-import php script,
*install the new airtime-import.py script and update the /usr/bin/symlink.
*/
// we don't need thses functions anymore as it's done in CreateSymlinksToUtils()
/*Airtime190Upgrade::removeOldAirtimeImport();
Airtime190Upgrade::updateAirtimeImportSymLink();*/
Airtime190Upgrade::connectToDatabase();
if(AirtimeInstall::DbTableExists('doctrine_migration_versions') === false) {
$migrations = array('20110312121200', '20110331111708', '20110402164819', '20110406182005');
foreach($migrations as $migration) {
AirtimeInstall::BypassMigrations(__DIR__, $migration);
}
}
/* adding music_dir and country table. 20110629143017 and 20110713161043 respetivly */
AirtimeInstall::MigrateTablesToVersion(__DIR__, '20110713161043');
AirtimeInstall::InsertCountryDataIntoDatabase();
// set up some keys in DB
AirtimeInstall::SetUniqueId();
AirtimeInstall::SetImportTimestamp();
AirtimeIni::CreateMonitFile();
exec("/etc/init.d/monit start");
AirtimeInstall::CreateSymlinksToUtils();
/* create cron file for phone home stat */
AirtimeInstall::CreateCronFile();
Airtime190Upgrade::backupFileInfoInStorToFile($values);
Airtime190Upgrade::installMediaMonitor($values);
AirtimeIni::upgradeConfigFiles();

View File

@ -1,23 +0,0 @@
[database]
host = localhost
dbname = airtime
dbuser = airtime
dbpass = airtime
[rabbitmq]
host = 127.0.0.1
port = 5672
user = guest
password = guest
vhost = /
[general]
api_key = AAA
web_server_user = www-data
airtime_dir = x
base_url = localhost
base_port = 80
[soundcloud]
connection_retries = 3
time_between_retries = 60

View File

@ -1,197 +0,0 @@
import os
import hashlib
import mutagen
import logging
import math
import re
def to_unicode(obj, encoding='utf-8'):
if isinstance(obj, basestring):
if not isinstance(obj, unicode):
obj = unicode(obj, encoding)
return obj
def encode_to(obj, encoding='utf-8'):
if isinstance(obj, basestring):
if not isinstance(obj, str):
obj = obj.encode(encoding)
return obj
"""
list of supported easy tags in mutagen version 1.20
['albumartistsort', 'musicbrainz_albumstatus', 'lyricist', 'releasecountry', 'date', 'performer', 'musicbrainz_albumartistid', 'composer', 'encodedby', 'tracknumber', 'musicbrainz_albumid', 'album', 'asin', 'musicbrainz_artistid', 'mood', 'copyright', 'author', 'media', 'length', 'version', 'artistsort', 'titlesort', 'discsubtitle', 'website', 'musicip_fingerprint', 'conductor', 'compilation', 'barcode', 'performer:*', 'composersort', 'musicbrainz_discid', 'musicbrainz_albumtype', 'genre', 'isrc', 'discnumber', 'musicbrainz_trmid', 'replaygain_*_gain', 'musicip_puid', 'artist', 'title', 'bpm', 'musicbrainz_trackid', 'arranger', 'albumsort', 'replaygain_*_peak', 'organization']
"""
class AirtimeMetadata:
def __init__(self):
self.airtime2mutagen = {\
"MDATA_KEY_TITLE": "title",\
"MDATA_KEY_CREATOR": "artist",\
"MDATA_KEY_SOURCE": "album",\
"MDATA_KEY_GENRE": "genre",\
"MDATA_KEY_MOOD": "mood",\
"MDATA_KEY_TRACKNUMBER": "tracknumber",\
"MDATA_KEY_BPM": "bpm",\
"MDATA_KEY_LABEL": "organization",\
"MDATA_KEY_COMPOSER": "composer",\
"MDATA_KEY_ENCODER": "encodedby",\
"MDATA_KEY_CONDUCTOR": "conductor",\
"MDATA_KEY_YEAR": "date",\
"MDATA_KEY_URL": "website",\
"MDATA_KEY_ISRC": "isrc",\
"MDATA_KEY_COPYRIGHT": "copyright",\
}
self.mutagen2airtime = {\
"title": "MDATA_KEY_TITLE",\
"artist": "MDATA_KEY_CREATOR",\
"album": "MDATA_KEY_SOURCE",\
"genre": "MDATA_KEY_GENRE",\
"mood": "MDATA_KEY_MOOD",\
"tracknumber": "MDATA_KEY_TRACKNUMBER",\
"bpm": "MDATA_KEY_BPM",\
"organization": "MDATA_KEY_LABEL",\
"composer": "MDATA_KEY_COMPOSER",\
"encodedby": "MDATA_KEY_ENCODER",\
"conductor": "MDATA_KEY_CONDUCTOR",\
"date": "MDATA_KEY_YEAR",\
"website": "MDATA_KEY_URL",\
"isrc": "MDATA_KEY_ISRC",\
"copyright": "MDATA_KEY_COPYRIGHT",\
}
self.logger = logging.getLogger()
def get_md5(self, filepath):
f = open(filepath, 'rb')
m = hashlib.md5()
m.update(f.read())
md5 = m.hexdigest()
return md5
## mutagen_length is in seconds with the format (d+).dd
## return format hh:mm:ss.uuu
def format_length(self, mutagen_length):
t = float(mutagen_length)
h = int(math.floor(t/3600))
t = t % 3600
m = int(math.floor(t/60))
s = t % 60
# will be ss.uuu
s = str(s)
seconds = s.split(".")
s = seconds[0]
# have a maximum of 6 subseconds.
if len(seconds[1]) >= 6:
ss = seconds[1][0:6]
else:
ss = seconds[1][0:]
length = "%s:%s:%s.%s" % (h, m, s, ss)
return length
def save_md_to_file(self, m):
try:
airtime_file = mutagen.File(m['MDATA_KEY_FILEPATH'], easy=True)
for key in m.keys() :
if key in self.airtime2mutagen:
value = m[key]
if (value is not None):
self.logger.debug("Saving %s to file", key)
self.logger.debug(value)
if isinstance(value, basestring) and (len(value) > 0):
airtime_file[self.airtime2mutagen[key]] = unicode(value, "utf-8")
elif isinstance(value, int):
airtime_file[self.airtime2mutagen[key]] = str(value)
airtime_file.save()
except Exception, e:
self.logger.error('Trying to save md')
self.logger.error('Exception: %s', e)
self.logger.error('Filepath %s', m['MDATA_KEY_FILEPATH'])
def get_md_from_file(self, filepath):
self.logger.info("getting info from filepath %s", filepath)
try:
md = {}
md5 = self.get_md5(filepath)
md['MDATA_KEY_MD5'] = md5
file_info = mutagen.File(filepath, easy=True)
except Exception, e:
self.logger.error("failed getting metadata from %s", filepath)
self.logger.error("Exception %s", e)
return None
self.logger.info(file_info)
if file_info is None:
return None
#check if file has any metadata
if file_info is not None:
for key in file_info.keys() :
if key in self.mutagen2airtime :
md[self.mutagen2airtime[key]] = file_info[key][0]
if 'MDATA_KEY_TITLE' not in md:
#get rid of file extention from original name, name might have more than 1 '.' in it.
#filepath = to_unicode(filepath)
#filepath = filepath.encode('utf-8')
original_name = os.path.basename(filepath)
original_name = original_name.split(".")[0:-1]
original_name = ''.join(original_name)
md['MDATA_KEY_TITLE'] = original_name
#incase track number is in format u'4/11'
#need to also check that the tracknumber is even a tracknumber (cc-2582)
if 'MDATA_KEY_TRACKNUMBER' in md:
try:
md['MDATA_KEY_TRACKNUMBER'] = int(md['MDATA_KEY_TRACKNUMBER'])
except Exception, e:
pass
if isinstance(md['MDATA_KEY_TRACKNUMBER'], basestring):
match = re.search('^(\d*/\d*)?', md['MDATA_KEY_TRACKNUMBER'])
if match.group(0) is not u'':
md['MDATA_KEY_TRACKNUMBER'] = int(md['MDATA_KEY_TRACKNUMBER'].split("/")[0])
else:
del md['MDATA_KEY_TRACKNUMBER']
#make sure bpm is valid, need to check more types of formats for this tag to assure correct parsing.
if 'MDATA_KEY_BPM' in md:
if isinstance(md['MDATA_KEY_BPM'], basestring):
try:
md['MDATA_KEY_BPM'] = int(md['MDATA_KEY_BPM'])
except Exception, e:
del md['MDATA_KEY_BPM']
md['MDATA_KEY_BITRATE'] = file_info.info.bitrate
md['MDATA_KEY_SAMPLERATE'] = file_info.info.sample_rate
md['MDATA_KEY_DURATION'] = self.format_length(file_info.info.length)
md['MDATA_KEY_MIME'] = file_info.mime[0]
if "mp3" in md['MDATA_KEY_MIME']:
md['MDATA_KEY_FTYPE'] = "audioclip"
elif "vorbis" in md['MDATA_KEY_MIME']:
md['MDATA_KEY_FTYPE'] = "audioclip"
#do this so object can be urlencoded properly.
for key in md.keys():
if (isinstance(md[key], basestring)):
#self.logger.info("Converting md[%s] = '%s' ", key, md[key])
md[key] = encode_to(md[key], 'utf-8')
#self.logger.info("Converting complete: md[%s] = '%s' ", key, md[key])
return md

View File

@ -1,24 +0,0 @@
import sys
from configobj import ConfigObj
class AirtimeMediaConfig:
MODE_CREATE = "create"
MODE_MODIFY = "modify"
MODE_MOVED = "moved"
MODE_DELETE = "delete"
def __init__(self, logger):
# loading config file
try:
config = ConfigObj('/etc/airtime/media-monitor.cfg')
self.cfg = config
except Exception, e:
logger.info('Error loading config: ', e)
sys.exit()
self.storage_directory = None

View File

@ -1,260 +0,0 @@
import os
import grp
import pwd
import logging
from subprocess import Popen, PIPE
from airtimemetadata import AirtimeMetadata
def encode_to(obj, encoding='utf-8'):
if isinstance(obj, basestring):
if not isinstance(obj, str):
obj = obj.encode(encoding)
return obj
class MediaMonitorCommon:
timestamp_file = "/var/tmp/airtime/last_index"
def __init__(self, airtime_config):
self.supported_file_formats = ['mp3', 'ogg']
self.logger = logging.getLogger()
self.config = airtime_config
self.md_manager = AirtimeMetadata()
def is_parent_directory(self, filepath, directory):
filepath = os.path.normpath(filepath)
directory = os.path.normpath(directory)
return (directory == filepath[0:len(directory)])
def is_temp_file(self, filename):
info = filename.split(".")
if(info[-2] in self.supported_file_formats):
return True
else:
return False
def is_audio_file(self, filename):
info = filename.split(".")
if(info[-1] in self.supported_file_formats):
return True
else:
return False
#check if file is readable by "nobody"
def has_correct_permissions(self, filepath):
#drop root permissions and become "nobody"
os.seteuid(65534)
try:
open(filepath)
readable = True
except IOError:
self.logger.warn("File does not have correct permissions: '%s'", filepath)
readable = False
except Exception, e:
self.logger.error("Unexpected exception thrown: %s", e)
readable = False
finally:
#reset effective user to root
os.seteuid(0)
return readable
def set_needed_file_permissions(self, item, is_dir):
try:
omask = os.umask(0)
uid = pwd.getpwnam('www-data')[2]
gid = grp.getgrnam('www-data')[2]
os.chown(item, uid, gid)
if is_dir is True:
os.chmod(item, 02777)
else:
os.chmod(item, 0666)
except Exception, e:
self.logger.error("Failed to change file's owner/group/permissions. %s", e)
finally:
os.umask(omask)
#checks if path is a directory, and if it doesnt exist, then creates it.
#Otherwise prints error to log file.
def ensure_is_dir(self, directory):
try:
omask = os.umask(0)
if not os.path.exists(directory):
os.makedirs(directory, 02777)
elif not os.path.isdir(directory):
#path exists but it is a file not a directory!
self.logger.error("path %s exists, but it is not a directory!!!")
finally:
os.umask(omask)
#moves file from source to dest but also recursively removes the
#the source file's parent directories if they are now empty.
def move_file(self, source, dest):
try:
omask = os.umask(0)
os.rename(source, dest)
except Exception, e:
self.logger.error("failed to move file. %s", e)
finally:
os.umask(omask)
dir = os.path.dirname(source)
self.cleanup_empty_dirs(dir)
#keep moving up the file hierarchy and deleting parent
#directories until we hit a non-empty directory, or we
#hit the organize dir.
def cleanup_empty_dirs(self, dir):
if os.path.normpath(dir) != self.config.organize_directory:
if len(os.listdir(dir)) == 0:
os.rmdir(dir)
pdir = os.path.dirname(dir)
self.cleanup_empty_dirs(pdir)
#checks if path exists already in stor. If the path exists and the md5s are the
#same just overwrite.
def create_unique_filename(self, filepath, old_filepath):
try:
if(os.path.exists(filepath)):
self.logger.info("Path %s exists", filepath)
self.logger.info("Checking if md5s are the same.")
md5_fp = self.md_manager.get_md5(filepath)
md5_ofp = self.md_manager.get_md5(old_filepath)
if(md5_fp == md5_ofp):
self.logger.info("Md5s are the same, moving to same filepath.")
return filepath
self.logger.info("Md5s aren't the same, appending to filepath.")
file_dir = os.path.dirname(filepath)
filename = os.path.basename(filepath).split(".")[0]
#will be in the format .ext
file_ext = os.path.splitext(filepath)[1]
i = 1;
while(True):
new_filepath = '%s/%s(%s)%s' % (file_dir, filename, i, file_ext)
self.logger.error("Trying %s", new_filepath)
if(os.path.exists(new_filepath)):
i = i+1;
else:
filepath = new_filepath
break
except Exception, e:
self.logger.error("Exception %s", e)
return filepath
#create path in /srv/airtime/stor/imported/[song-metadata]
def create_file_path(self, original_path, orig_md):
storage_directory = self.config.storage_directory
is_recorded_show = False
try:
#will be in the format .ext
file_ext = os.path.splitext(original_path)[1]
file_ext = encode_to(file_ext, 'utf-8')
path_md = ['MDATA_KEY_TITLE', 'MDATA_KEY_CREATOR', 'MDATA_KEY_SOURCE', 'MDATA_KEY_TRACKNUMBER', 'MDATA_KEY_BITRATE']
md = {}
for m in path_md:
if m not in orig_md:
md[m] = encode_to(u'unknown', 'utf-8')
else:
#get rid of any "/" which will interfere with the filepath.
if isinstance(orig_md[m], basestring):
md[m] = orig_md[m].replace("/", "-")
else:
md[m] = orig_md[m]
if 'MDATA_KEY_TRACKNUMBER' in orig_md:
#make sure all track numbers are at least 2 digits long in the filepath.
md['MDATA_KEY_TRACKNUMBER'] = "%02d" % (int(md['MDATA_KEY_TRACKNUMBER']))
#format bitrate as 128kbps
md['MDATA_KEY_BITRATE'] = str(md['MDATA_KEY_BITRATE']/1000)+"kbps"
filepath = None
#file is recorded by Airtime
#/srv/airtime/stor/recorded/year/month/year-month-day-time-showname-bitrate.ext
if(md['MDATA_KEY_CREATOR'] == encode_to("Airtime Show Recorder", 'utf-8')):
#yyyy-mm-dd-hh-MM-ss
y = orig_md['MDATA_KEY_YEAR'].split("-")
filepath = '%s/%s/%s/%s/%s-%s-%s%s' % (storage_directory, encode_to("recorded", 'utf-8'), y[0], y[1], orig_md['MDATA_KEY_YEAR'], md['MDATA_KEY_TITLE'], md['MDATA_KEY_BITRATE'], file_ext)
#"Show-Title-2011-03-28-17:15:00"
title = md['MDATA_KEY_TITLE'].split("-")
show_hour = title[0]
show_min = title[1]
show_sec = title[2]
show_name = '-'.join(title[3:])
new_md = {}
new_md["MDATA_KEY_FILEPATH"] = original_path
new_md['MDATA_KEY_TITLE'] = '%s-%s-%s:%s:%s' % (show_name, orig_md['MDATA_KEY_YEAR'], show_hour, show_min, show_sec)
self.md_manager.save_md_to_file(new_md)
elif(md['MDATA_KEY_TRACKNUMBER'] == encode_to(u'unknown', 'utf-8')):
filepath = '%s/%s/%s/%s/%s-%s%s' % (storage_directory, encode_to("imported", 'utf-8'), md['MDATA_KEY_CREATOR'], md['MDATA_KEY_SOURCE'], md['MDATA_KEY_TITLE'], md['MDATA_KEY_BITRATE'], file_ext)
else:
filepath = '%s/%s/%s/%s/%s-%s-%s%s' % (storage_directory, encode_to("imported", 'utf-8'), md['MDATA_KEY_CREATOR'], md['MDATA_KEY_SOURCE'], md['MDATA_KEY_TRACKNUMBER'], md['MDATA_KEY_TITLE'], md['MDATA_KEY_BITRATE'], file_ext)
filepath = self.create_unique_filename(filepath, original_path)
self.logger.info('Unique filepath: %s', filepath)
self.ensure_is_dir(os.path.dirname(filepath))
except Exception, e:
self.logger.error('Exception: %s', e)
return filepath
def exec_command(self, command):
p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if p.returncode != 0:
self.logger.warn("command \n%s\n return with a non-zero return value", command)
self.logger.error(stderr)
return stdout
def scan_dir_for_new_files(self, dir):
command = 'find "%s" -type f -iname "*.ogg" -o -iname "*.mp3" -readable' % dir.replace('"', '\\"')
self.logger.debug(command)
stdout = self.exec_command(command)
return stdout.splitlines()
def touch_index_file(self):
open(self.timestamp_file, "w")
def organize_new_file(self, pathname):
self.logger.info("Organizing new file: %s", pathname)
file_md = self.md_manager.get_md_from_file(pathname)
if file_md is not None:
filepath = self.create_file_path(pathname, file_md)
self.logger.debug("Moving from %s to %s", pathname, filepath)
self.move_file(pathname, filepath)
else:
filepath = None
self.logger.warn("File %s, has invalid metadata", pathname)
return filepath

View File

@ -1,89 +0,0 @@
bin_dir = "/usr/lib/airtime/api_clients"
#############################
## Common
#############################
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
# Hostname
base_url = 'localhost'
base_port = 80
#############################
## Config for Media Monitor
#############################
# URL to setup the media monitor
media_setup_url = 'media-monitor-setup/format/json/api_key/%%api_key%%'
# Tell Airtime the file id associated with a show instance.
upload_recorded = 'upload-recorded/format/json/api_key/%%api_key%%/fileid/%%fileid%%/showinstanceid/%%showinstanceid%%'
# URL to tell Airtime to update file's meta data
update_media_url = 'reload-metadata/format/json/api_key/%%api_key%%/mode/%%mode%%'
# URL to tell Airtime we want a listing of all files it knows about
list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%'
# URL to tell Airtime we want a listing of all dirs its watching (including the stor dir)
list_all_watched_dirs = 'list-all-watched-dirs/format/json/api_key/%%api_key%%'
# URL to tell Airtime we want to add watched directory
add_watched_dir = 'add-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
remove_watched_dir = 'remove-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
set_storage_dir = 'set-storage-dir/format/json/api_key/%%api_key%%/path/%%path%%'
#############################
## Config for Recorder
#############################
# URL to get the schedule of shows set to record
show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
# URL to upload the recorded show's file to Airtime
upload_file_url = 'upload-file/format/json/api_key/%%api_key%%'
#number of retries to upload file if connection problem
upload_retries = 3
#time to wait between attempts to upload file if connection problem (in seconds)
upload_wait = 60
################################################################################
# Uncomment *one of the sets* of values from the API clients below, and comment
# out all the others.
################################################################################
#############################
## Config for Pypo
#############################
# Schedule export path.
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
export_url = 'schedule/api_key/%%api_key%%'
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
# Update whether a schedule group has begun playing.
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
# Update whether an audio clip is currently playing.
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
# ???
generate_range_url = 'generate_range_dp.php'

View File

@ -1,74 +0,0 @@
<?php
/* THIS FILE IS NOT MEANT FOR CUSTOMIZING.
* PLEASE EDIT THE FOLLOWING TO CHANGE YOUR CONFIG:
* /etc/airtime/airtime.conf
* /etc/airtime/pypo.cfg
* /etc/airtime/recorder.cfg
*/
global $CC_CONFIG;
$CC_CONFIG = array(
// prefix for table names in the database
'tblNamePrefix' => 'cc_',
/* ================================================ storage configuration */
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
"rootDir" => __DIR__."/../.."
);
$CC_CONFIG = Config::loadConfig($CC_CONFIG);
// Add database table names
$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';
$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents';
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes';
$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule';
$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days';
$CC_CONFIG['showTable'] = $CC_CONFIG['tblNamePrefix'].'show';
$CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances';
$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';
$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
class Config {
public static function loadConfig($CC_CONFIG) {
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
// Name of the web server user
$CC_CONFIG['webServerUser'] = $values['general']['web_server_user'];
$CC_CONFIG['rabbitmq'] = $values['rabbitmq'];
$CC_CONFIG['baseUrl'] = $values['general']['base_url'];
$CC_CONFIG['basePort'] = $values['general']['base_port'];
// 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_CONFIG['apiKey'] = array($values['general']['api_key']);
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
return $CC_CONFIG;
}
}

View File

@ -1,55 +0,0 @@
###########################################
# Liquidsoap config file #
###########################################
###########################################
# Output settings #
###########################################
output_sound_device = false
output_icecast_vorbis = true
output_icecast_mp3 = false
output_shoutcast = false
#output_bitrate = 128
#output_samplerate = 44100
#output_stereo = true
###########################################
# Logging settings #
###########################################
log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"
#log_level = 3
###########################################
# Icecast Stream settings #
###########################################
icecast_host = "127.0.0.1"
icecast_port = 8000
icecast_pass = "hackme"
# Icecast mountpoint names
mount_point_mp3 = "airtime.mp3"
mount_point_vorbis = "airtime.ogg"
# Webstream metadata settings
icecast_url = "http://airtime.sourcefabric.org"
icecast_description = "Airtime Radio!"
icecast_genre = "genre"
# Audio stream metadata for vorbis/ogg is disabled by default
# due to a number of client media players that disconnect
# when the metadata changes to a new track. Some versions of
# mplayer and VLC have this problem. Enable this option at your
# own risk!
output_icecast_vorbis_metadata = false
###########################################
# Shoutcast Stream settings #
###########################################
shoutcast_host = "127.0.0.1"
shoutcast_port = 9000
shoutcast_pass = "testing"
# Webstream metadata settings
shoutcast_url = "http://airtime.sourcefabric.org"
shoutcast_genre = "genre"

View File

@ -1,22 +0,0 @@
[loggers]
keys=root
[handlers]
keys=fileOutHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=DEBUG
handlers=fileOutHandler
[handler_fileOutHandler]
class=logging.handlers.RotatingFileHandler
level=DEBUG
formatter=simpleFormatter
args=("/var/log/airtime/media-monitor/media-monitor.log", 'a', 1000000, 5,)
[formatter_simpleFormatter]
format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s
datefmt=

View File

@ -1,131 +0,0 @@
from airtimefilemonitor.mediamonitorcommon import MediaMonitorCommon
from airtimefilemonitor.mediaconfig import AirtimeMediaConfig
import logging
import logging.config
import sys
import os
import json
import ConfigParser
import pwd
import grp
import subprocess
import re
import os.path
# configure logging
try:
logging.config.fileConfig("logging.cfg")
except Exception, e:
print 'Error configuring logging: ', e
sys.exit(1)
logger = logging.getLogger()
mmconfig = AirtimeMediaConfig(logger)
#get stor folder location from /etc/airtime/airtime.conf
config = ConfigParser.RawConfigParser()
config.read('/etc/airtime/airtime.conf')
stor_dir = config.get('general', 'base_files_dir') + "/stor"
organize_dir = stor_dir + '/organize'
mmconfig.storage_directory = os.path.normpath(stor_dir)
mmconfig.imported_directory = os.path.normpath(stor_dir + '/imported')
mmconfig.organize_directory = os.path.normpath(organize_dir)
mmc = MediaMonitorCommon(mmconfig)
try:
os.makedirs(organize_dir)
except Exception, e:
#organize dir already exists. ( really shouldn't though )
pass
#older versions of Airtime installed from repository at least had owner of stor dir as "root"
mmc.set_needed_file_permissions(stor_dir, True)
mmc.set_needed_file_permissions(organize_dir, True)
#read list of all files in stor location.....and one-by-one pass this through to
#mmc.organize_files. print out json encoding of before and after
pairs = []
f = open('storDump.txt','r')
for line in f.readlines():
db_md = line.split("SF_BACKUP_1.9.0")
#remove newlines.
for i in range(0, len(db_md)):
db_md[i] = db_md[i].strip()
logger.debug(db_md)
file_md = {}
old_filepath = db_md[1]
file_md["MDATA_KEY_FILEPATH"] = old_filepath
#file is recorded
#format 1 title year month day hour min
if int(db_md[0]):
file_md["MDATA_KEY_TITLE"] = db_md[2]
match = re.search('^.*(?=\-\d{4}\-\d{2}\-\d{2}\-\d{2}:\d{2}:\d{2}\.(mp3|ogg))', file_md["MDATA_KEY_TITLE"])
#"Show-Title-2011-03-28-17:15:00.mp3"
if match:
file_md["MDATA_KEY_TITLE"] = match.group(0)
file_md["MDATA_KEY_TITLE"] = file_md["MDATA_KEY_TITLE"].replace(" ", "-")
file_md["MDATA_KEY_TITLE"] = db_md[6]+"-"+db_md[7]+"-00-"+file_md["MDATA_KEY_TITLE"]
file_md["MDATA_KEY_YEAR"] = db_md[3]+"-"+db_md[4]+"-"+db_md[5]
file_md["MDATA_KEY_CREATOR"] = "Airtime Show Recorder".encode('utf-8')
#file is regular audio file
#format 0 title artist album track
else:
file_md["MDATA_KEY_TITLE"] = db_md[2]
match = re.search('^.*(?=\.mp3|\.ogg)', file_md["MDATA_KEY_TITLE"])
#"test.mp3" -> "test"
if match:
file_md["MDATA_KEY_TITLE"] = match.group(0)
if len(db_md[3]) > 0:
file_md["MDATA_KEY_CREATOR"] = db_md[3]
if len(db_md[4]) > 0:
file_md["MDATA_KEY_SOURCE"] = db_md[4]
if len(db_md[5]) > 0:
file_md["MDATA_KEY_TRACKNUMBER"] = int(db_md[5])
mmc.md_manager.save_md_to_file(file_md)
#new_filepath = mmc.organize_new_file(old_filepath)
#if new_filepath is not None:
#pair = old_filepath, new_filepath
#pairs.append(pair)
#mmc.set_needed_file_permissions(new_filepath, False)
f.close()
for root, dirs, files in os.walk(mmconfig.storage_directory):
for f in files:
old_filepath = os.path.join(root, f)
new_filepath = mmc.organize_new_file(old_filepath)
if new_filepath is not None:
pair = old_filepath, new_filepath
pairs.append(pair)
mmc.set_needed_file_permissions(new_filepath, False)
#incase file has a metadata problem.
else:
pair = old_filepath, old_filepath
pairs.append(pair)
mmc.set_needed_file_permissions(old_filepath, False)
#need to set all the dirs in imported to be owned by www-data.
command = "chown -R www-data " + stor_dir
subprocess.call(command.split(" "))
print json.dumps(pairs)

View File

@ -1,21 +0,0 @@
api_client = "airtime"
# where the binary files live
bin_dir = '/usr/lib/airtime/media-monitor'
# where the logging files live
log_dir = '/var/log/airtime/media-monitor'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
############################################
# Media-Monitor preferences #
############################################
check_filesystem_events = 5 #how long to queue up events performed on the files themselves.
check_airtime_events = 30 #how long to queue metadata input from airtime.

View File

@ -1,28 +0,0 @@
<?php
// This file generated by Propel 1.5.2 convert-conf target - with modifications by Martin
// from XML runtime conf file /home/naomiaro/dev-campcaster/campcaster/build/runtime-conf.xml
$ini = parse_ini_file('/etc/airtime/airtime.conf', true);
$dbhost = $ini['database']['host'];
$dbname = $ini['database']['dbname'];
$dbuser = $ini['database']['dbuser'];
$dbpass = $ini['database']['dbpass'];
$conf = array (
'datasources' =>
array (
'airtime' =>
array (
'adapter' => 'pgsql',
'connection' =>
array (
'dsn' => "pgsql:host=$dbhost;port=5432;dbname=$dbname;user=$dbuser;password=$dbpass",
),
),
'default' => 'airtime',
),
'generator_version' => '1.5.2',
);
$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-airtime-conf.php');
return $conf;

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_access' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcAccess extends BaseCcAccess {
} // CcAccess

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_access' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcAccessPeer extends BaseCcAccessPeer {
} // CcAccessPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_access' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcAccessQuery extends BaseCcAccessQuery {
} // CcAccessQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_backup' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcBackup extends BaseCcBackup {
} // CcBackup

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_backup' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcBackupPeer extends BaseCcBackupPeer {
} // CcBackupPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_backup' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcBackupQuery extends BaseCcBackupQuery {
} // CcBackupQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_country' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcCountry extends BaseCcCountry {
} // CcCountry

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_country' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcCountryPeer extends BaseCcCountryPeer {
} // CcCountryPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_country' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcCountryQuery extends BaseCcCountryQuery {
} // CcCountryQuery

View File

@ -1,31 +0,0 @@
<?php
require_once('Common.php');
/**
* Skeleton subclass for representing a row from the 'cc_files' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcFiles extends BaseCcFiles {
public function getDbLength()
{
return $this->length;
}
public function setDbLength($time)
{
$this->length = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::LENGTH;
return Common::setTimeInSub($this, 'LENGTH', $time);
}
} // CcFiles

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_files' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcFilesPeer extends BaseCcFilesPeer {
} // CcFilesPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_files' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcFilesQuery extends BaseCcFilesQuery {
} // CcFilesQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_music_dirs' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcMusicDirs extends BaseCcMusicDirs {
} // CcMusicDirs

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_music_dirs' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcMusicDirsPeer extends BaseCcMusicDirsPeer {
} // CcMusicDirsPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_music_dirs' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcMusicDirsQuery extends BaseCcMusicDirsQuery {
} // CcMusicDirsQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_perms' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPerms extends BaseCcPerms {
} // CcPerms

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_perms' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPermsPeer extends BaseCcPermsPeer {
} // CcPermsPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_perms' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPermsQuery extends BaseCcPermsQuery {
} // CcPermsQuery

View File

@ -1,48 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playlist' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylist extends BaseCcPlaylist {
public function computeLastPosition()
{
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$sql = 'SELECT MAX('.CcPlaylistcontentsPeer::POSITION.') AS pos'
. ' FROM ' .CcPlaylistcontentsPeer::TABLE_NAME
. ' WHERE ' .CcPlaylistcontentsPeer::PLAYLIST_ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
public function computeLength()
{
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$sql = 'SELECT SUM('.CcPlaylistcontentsPeer::CLIPLENGTH.') AS length'
. ' FROM ' .CcPlaylistcontentsPeer::TABLE_NAME
. ' WHERE ' .CcPlaylistcontentsPeer::PLAYLIST_ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
} // CcPlaylist

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlist' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPlaylistPeer extends BaseCcPlaylistPeer {
} // CcPlaylistPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlist' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPlaylistQuery extends BaseCcPlaylistQuery {
} // CcPlaylistQuery

View File

@ -1,81 +0,0 @@
<?php
require_once('Common.php');
/**
* Skeleton subclass for representing a row from the 'cc_playlistcontents' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylistcontents extends BaseCcPlaylistcontents {
public function getDbFadein()
{
return $this->fadein;
}
public function setDbFadein($time)
{
$this->fadein = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN;
Common::setTimeInSub($this, 'FADEIN', $time);
}
public function getDbFadeout()
{
return $this->fadeout;
}
public function setDbFadeout($time)
{
$this->fadeout = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT;
Common::setTimeInSub($this, 'FADEOUT', $time);
}
public function getDbCuein()
{
return $this->cuein;
}
public function setDbCuein($time)
{
$this->cuein = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN;
Common::setTimeInSub($this, 'CUEIN', $time);
}
public function getDbCueout()
{
return $this->cueout;
}
public function setDbCueout($time)
{
$this->cueout = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT;
Common::setTimeInSub($this, 'CUEOUT', $time);
}
public function getDbCliplength()
{
return $this->cliplength;
}
public function setDbCliplength($time)
{
$this->cliplength = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH;
Common::setTimeInSub($this, 'CLIPLENGTH', $time);
}
} // CcPlaylistcontents

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlistcontents' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPlaylistcontentsPeer extends BaseCcPlaylistcontentsPeer {
} // CcPlaylistcontentsPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlistcontents' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPlaylistcontentsQuery extends BaseCcPlaylistcontentsQuery {
} // CcPlaylistcontentsQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_pref' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPref extends BaseCcPref {
} // CcPref

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_pref' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPrefPeer extends BaseCcPrefPeer {
} // CcPrefPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_pref' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcPrefQuery extends BaseCcPrefQuery {
} // CcPrefQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_schedule' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSchedule extends BaseCcSchedule {
} // CcSchedule

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_schedule' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSchedulePeer extends BaseCcSchedulePeer {
} // CcSchedulePeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_schedule' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcScheduleQuery extends BaseCcScheduleQuery {
} // CcScheduleQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_sess' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSess extends BaseCcSess {
} // CcSess

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_sess' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSessPeer extends BaseCcSessPeer {
} // CcSessPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_sess' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSessQuery extends BaseCcSessQuery {
} // CcSessQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShow extends BaseCcShow {
} // CcShow

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_days' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowDays extends BaseCcShowDays {
} // CcShowDays

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_days' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowDaysPeer extends BaseCcShowDaysPeer {
} // CcShowDaysPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_days' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowDaysQuery extends BaseCcShowDaysQuery {
} // CcShowDaysQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_hosts' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowHosts extends BaseCcShowHosts {
} // CcShowHosts

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_hosts' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowHostsPeer extends BaseCcShowHostsPeer {
} // CcShowHostsPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_hosts' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowHostsQuery extends BaseCcShowHostsQuery {
} // CcShowHostsQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_instances' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowInstances extends BaseCcShowInstances {
} // CcShowInstances

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_instances' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowInstancesPeer extends BaseCcShowInstancesPeer {
} // CcShowInstancesPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_instances' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowInstancesQuery extends BaseCcShowInstancesQuery {
} // CcShowInstancesQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowPeer extends BaseCcShowPeer {
} // CcShowPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowQuery extends BaseCcShowQuery {
} // CcShowQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_rebroadcast' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowRebroadcast extends BaseCcShowRebroadcast {
} // CcShowRebroadcast

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_rebroadcast' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowRebroadcastPeer extends BaseCcShowRebroadcastPeer {
} // CcShowRebroadcastPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_rebroadcast' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowRebroadcastQuery extends BaseCcShowRebroadcastQuery {
} // CcShowRebroadcastQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_schedule' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowSchedule extends BaseCcShowSchedule {
} // CcShowSchedule

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_schedule' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowSchedulePeer extends BaseCcShowSchedulePeer {
} // CcShowSchedulePeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_schedule' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcShowScheduleQuery extends BaseCcShowScheduleQuery {
} // CcShowScheduleQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_smemb' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSmemb extends BaseCcSmemb {
} // CcSmemb

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_smemb' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSmembPeer extends BaseCcSmembPeer {
} // CcSmembPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_smemb' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSmembQuery extends BaseCcSmembQuery {
} // CcSmembQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_subjs' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSubjs extends BaseCcSubjs {
} // CcSubjs

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_subjs' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSubjsPeer extends BaseCcSubjsPeer {
} // CcSubjsPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_subjs' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcSubjsQuery extends BaseCcSubjsQuery {
} // CcSubjsQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_trans' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcTrans extends BaseCcTrans {
} // CcTrans

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_trans' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcTransPeer extends BaseCcTransPeer {
} // CcTransPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_trans' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CcTransQuery extends BaseCcTransQuery {
} // CcTransQuery

View File

@ -1,19 +0,0 @@
<?php
class Common {
public static function setTimeInSub($row, $col, $time)
{
$class = get_class($row).'Peer';
$con = Propel::getConnection($class::DATABASE_NAME);
$sql = 'UPDATE '.$class::TABLE_NAME
. ' SET '.$col.' = :f1'
. ' WHERE ' .$class::ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':f1', $time);
$stmt->bindValue(':p1', $row->getDbId());
$stmt->execute();
}
}

Some files were not shown because too many files have changed in this diff Show More