Merge branch 'master' of dev.sourcefabric.org:airtime into 1.8.1
Conflicts: VERSION airtime_mvc/application/configs/conf.php
This commit is contained in:
commit
9236f4941d
57
CREDITS
57
CREDITS
|
@ -19,51 +19,24 @@ Daniel James
|
||||||
Paul Baranowski (paul.baranowski@sourcefabric.org)
|
Paul Baranowski (paul.baranowski@sourcefabric.org)
|
||||||
Role: Project Manager
|
Role: Project Manager
|
||||||
|
|
||||||
Version 1.8.0
|
|
||||||
-------------
|
|
||||||
-The calendar is now faster by 5-8X. For example, if the "month" calendar view had shows scheduled for every hour of every day, it used to take 16 seconds to load. Now it takes 2 seconds.
|
|
||||||
-Users can now edit shows. Now it is possible to change a show after it is created - you can change the simple stuff, like "Name", "Description", and "URL", but also change the complex stuff like repeat days and rebroadcast days.
|
|
||||||
-It is possible to have up to ten rebroadcast shows now, previously it was only up to five. Rebroadcast shows are hidden
|
|
||||||
-New improved look & feel of the calendar (thanks to the "FullCalendar" jQuery project).
|
|
||||||
-Installation now puts files in standard locations in the Linux file hierarchy, which prepares the project to be accepted into Ubuntu and Debian. Also because of our wish to be part of those projects, the default output stream type is now OGG instead of MP3 -- due to MP3 licensing issues. This configuration can be changed in "/etc/airtime/liquidsoap.conf".
|
|
||||||
-You now have the ability to start and stop pypo and the show recorder from the command line with the commands "airtime-pypo-start", "airtime-pypo-stop", "airtime-show-recorder-start", and "airtime-show-recorder-stop".
|
|
||||||
-The installation script now has two options: --perserve to keep your existing config files, or --overwrite to replace your existing config files with new ones.
|
|
||||||
-Uninstall will no longer remove your Airtime config files or remove your music storage directory.
|
|
||||||
-Bug fixes:
|
|
||||||
-CC-2192 Schedule sent to pypo is not sorted by start time.
|
|
||||||
-CC-2175 Overbooking: Cut off shows when they are done
|
|
||||||
-CC-2174 Need formatting and a warning icon for the message for overbooking a show
|
|
||||||
-CC-2039 Upload file: file name cropped
|
|
||||||
-CC-2177 Schedule editing does not work under Firefox 4
|
|
||||||
|
|
||||||
|
|
||||||
Version 1.7.0
|
Version 1.7.0
|
||||||
-------------
|
-------------
|
||||||
-Recording and automatic scheduling/broadcasting of live shows
|
Naomi Aro (naomi.aro@sourcefabric.org)
|
||||||
-Recording/rebroadcast status of a show is shown in "Now Playing" and "Calendar"
|
Role: Software Developer
|
||||||
-Can rebroadcast a show at multiple times and dates
|
|
||||||
-Automatic upload of recorded shows to Soundcloud
|
Martin Konecny (martin.konecny@sourcefabric.org)
|
||||||
-Frontend JQuery widgets for public-facing websites to show your visitors what's playing and the upcoming schedule
|
Role: Software Developer
|
||||||
-Ability to over-book a show and automatically cut and fade out song if it goes beyond the show time
|
|
||||||
-Ability to delete audio files
|
Ofir Gal (ofir.gal@sourcefabric.org)
|
||||||
-Ability to cancel the currently playing show
|
Role: QA
|
||||||
-Any changes to the schedule are immediately seen by the playout engine
|
|
||||||
-In version 1.6, you had to make sure that your show was ready to go 30 seconds before it started.
|
Daniel James
|
||||||
-Upgrade support (should be able to upgrade from any version, unlike 1.6.1 which required an uninstall of 1.6.0 first)
|
Role: Documentor & QA
|
||||||
-"Now Playing" list view:
|
|
||||||
-audio items are now grouped by show.
|
Paul Baranowski (paul.baranowski@sourcefabric.org)
|
||||||
-If a show is not fully scheduled, the user is notified how many seconds of silence are at the end of the show in this View.
|
Role: Project Manager
|
||||||
-Audio items that play past the show's end time have a visual notification that they will be cut off
|
|
||||||
-Ability to change metadata tag display format for web streams
|
|
||||||
-Config files moved to /etc/airtime. This means all config files are in one convenient location and separated from the code, so you can -upgrade your code independently of your config files.
|
|
||||||
-Redesign of Preferences screen
|
|
||||||
-Bug fixes:
|
|
||||||
-CC-2082 OGG stream dies after every song when using MPlayer
|
|
||||||
-CC-1894 Warn users about time zone differences or clock drift problems on the server
|
|
||||||
-CC-2058 Utilities are not in the system $PATH
|
|
||||||
-CC-2051 Unable to change user password
|
|
||||||
-CC-2030 Icon needed for Cue In/Out
|
|
||||||
-CC-1955 Special character support in the library search
|
|
||||||
|
|
||||||
Version 1.6.1
|
Version 1.6.1
|
||||||
-------------
|
-------------
|
||||||
|
|
36
Changelog
36
Changelog
|
@ -1,10 +1,36 @@
|
||||||
1.8.0 - April 19, 2011
|
1.8.0 - April 19, 2011
|
||||||
* Ability to edit a show
|
* The biggest feature of this release is the ability to edit shows. You can
|
||||||
* Speedup of calendar (approx to 5-8x faster now)
|
change everything from ‘Name’, ‘Description’, and ‘URL’, to repeat and
|
||||||
* Install process now put files in the right place for linux systems
|
rebroadcast days. Show instances will be dynamically created or removed as
|
||||||
* Improvements to upgrade framework
|
needed. Radio stations will be pleased to know they can now have up to
|
||||||
|
ten rebroadcast shows too.
|
||||||
|
* Airtime’s calendar now looks, feels and performs better than ever. Loading
|
||||||
|
a station schedule is now five to eight times faster. In our tests of 1.7,
|
||||||
|
if the month calendar had shows scheduled for every hour of every day, it
|
||||||
|
used to take 16 seconds to load. Now in 1.8 it takes two seconds.
|
||||||
|
* It is possible to have up to ten rebroadcast shows now, in 1.7 it was only
|
||||||
|
up to five.
|
||||||
|
* Airtime’s new installation script has two options for increased install
|
||||||
|
flexibility: --preserve to keep your existing config files, or --overwrite
|
||||||
|
to replace your existing config files with new ones. Uninstall no longer
|
||||||
|
removes Airtime config files or the music storage directory.
|
||||||
|
* New improved look & feel of the calendar (thanks to the "FullCalendar"
|
||||||
|
jQuery project).
|
||||||
|
* Installation now puts files in standard locations in the Linux file
|
||||||
|
hierarchy, which prepares the project to be accepted into Ubuntu and Debian.
|
||||||
|
Also because of our wish to be part of those projects, the default output
|
||||||
|
stream type is now OGG instead of MP3 -- due to MP3 licensing issues.
|
||||||
|
This configuration can be changed in "/etc/airtime/liquidsoap.conf".
|
||||||
|
* You now have the ability to start and stop pypo and the show recorder from
|
||||||
|
the command line with the commands "airtime-pypo-start",
|
||||||
|
"airtime-pypo-stop", "airtime-show-recorder-start", and
|
||||||
|
"airtime-show-recorder-stop".
|
||||||
* Bug fixes:
|
* Bug fixes:
|
||||||
o CC-2192 Schedule sent to pypo is not sorted by start time.
|
* CC-2192 Schedule sent to pypo is not sorted by start time.
|
||||||
|
* CC-2175 Overbooking: Cut off shows when they are done
|
||||||
|
* CC-2174 Need formatting and a warning icon for the message for overbooking a show
|
||||||
|
* CC-2039 Upload file: file name cropped
|
||||||
|
* CC-2177 Schedule editing does not work under Firefox 4
|
||||||
|
|
||||||
1.7.0 - April 4, 2011
|
1.7.0 - April 4, 2011
|
||||||
* Recording and automatic scheduling/broadcasting of live shows
|
* Recording and automatic scheduling/broadcasting of live shows
|
||||||
|
|
|
@ -10,6 +10,7 @@ Propel::init(__DIR__."/configs/airtime-conf.php");
|
||||||
$tz = ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC';
|
$tz = ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC';
|
||||||
date_default_timezone_set($tz);
|
date_default_timezone_set($tz);
|
||||||
|
|
||||||
|
require_once __DIR__."/logging/Logging.php";
|
||||||
require_once __DIR__."/configs/constants.php";
|
require_once __DIR__."/configs/constants.php";
|
||||||
require_once __DIR__."/configs/conf.php";
|
require_once __DIR__."/configs/conf.php";
|
||||||
require_once 'DB.php';
|
require_once 'DB.php';
|
||||||
|
@ -33,8 +34,8 @@ if (PEAR::isError($CC_DBC)) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
|
Logging::setLogPath('/var/log/airtime/zendphp.log');
|
||||||
|
|
||||||
//Zend_Session::start();
|
|
||||||
Zend_Validate::setDefaultNamespaces("Zend");
|
Zend_Validate::setDefaultNamespaces("Zend");
|
||||||
|
|
||||||
$front = Zend_Controller_Front::getInstance();
|
$front = Zend_Controller_Front::getInstance();
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Logging {
|
||||||
|
|
||||||
|
private static $_logger;
|
||||||
|
private static $_path;
|
||||||
|
|
||||||
|
public static function getLogger(){
|
||||||
|
if (!isset(self::$logger)) {
|
||||||
|
$writer = new Zend_Log_Writer_Stream(self::$_path);
|
||||||
|
self::$_logger = new Zend_Log($writer);
|
||||||
|
}
|
||||||
|
return self::$_logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setLogPath($path){
|
||||||
|
self::$_path = $path;
|
||||||
|
}
|
||||||
|
}
|
|
@ -113,6 +113,12 @@ class Playlist {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function deleteAll()
|
||||||
|
{
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
$sql = 'DELETE FROM '.$CC_CONFIG["playListTable"];
|
||||||
|
$CC_DBC->query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the file from all playlists.
|
* Delete the file from all playlists.
|
||||||
|
|
|
@ -60,10 +60,9 @@ class ScheduleGroup {
|
||||||
if (empty($length)) {
|
if (empty($length)) {
|
||||||
return new PEAR_Error("Length is empty.");
|
return new PEAR_Error("Length is empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert into the table
|
// Insert into the table
|
||||||
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
|
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
|
||||||
|
|
||||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||||
." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)"
|
." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)"
|
||||||
." VALUES ($p_showInstance, TIMESTAMP '$p_datetime', "
|
." VALUES ($p_showInstance, TIMESTAMP '$p_datetime', "
|
||||||
|
@ -76,7 +75,7 @@ class ScheduleGroup {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif (!is_null($p_playlistId)){
|
elseif (!is_null($p_playlistId)){
|
||||||
// Schedule a whole playlist
|
// Schedule a whole playlist
|
||||||
|
|
||||||
|
@ -606,7 +605,7 @@ class Schedule {
|
||||||
} else {
|
} else {
|
||||||
$range_end = Schedule::PypoTimeToAirtimeTime($p_toDateTime);
|
$range_end = Schedule::PypoTimeToAirtimeTime($p_toDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scheduler wants everything in a playlist
|
// Scheduler wants everything in a playlist
|
||||||
$data = Schedule::GetItems($range_start, $range_end, true);
|
$data = Schedule::GetItems($range_start, $range_end, true);
|
||||||
$playlists = array();
|
$playlists = array();
|
||||||
|
@ -681,5 +680,11 @@ class Schedule {
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function deleteAll()
|
||||||
|
{
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
$CC_DBC->query("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,26 +128,26 @@ class Show {
|
||||||
* then all show instances that occur on Sunday are removed.
|
* then all show instances that occur on Sunday are removed.
|
||||||
*
|
*
|
||||||
* @param array p_uncheckedDays
|
* @param array p_uncheckedDays
|
||||||
* An array specifying which days
|
* An array specifying which days
|
||||||
*/
|
*/
|
||||||
public function removeUncheckedDaysInstances($p_uncheckedDays)
|
public function removeUncheckedDaysInstances($p_uncheckedDays)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
|
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
|
|
||||||
$date = new DateHelper;
|
$date = new DateHelper;
|
||||||
$timestamp = $date->getTimestamp();
|
$timestamp = $date->getTimestamp();
|
||||||
|
|
||||||
$sql = "DELETE FROM cc_show_instances"
|
$sql = "DELETE FROM cc_show_instances"
|
||||||
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
|
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
|
||||||
." AND starts > TIMESTAMP '$timestamp'"
|
." AND starts > TIMESTAMP '$timestamp'"
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the current show originated
|
* Check whether the current show originated
|
||||||
* from a recording.
|
* from a recording.
|
||||||
|
@ -178,7 +178,7 @@ class Show {
|
||||||
->filterByDbRebroadcast(1)
|
->filterByDbRebroadcast(1)
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
return !is_null($showInstancesRow);
|
return !is_null($showInstancesRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,12 +187,12 @@ class Show {
|
||||||
* YYYY-MM-DD and time would HH:MM
|
* YYYY-MM-DD and time would HH:MM
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* array of associate arrays containing "start_date" and "start_time"
|
* array of associate arrays containing "start_date" and "start_time"
|
||||||
*/
|
*/
|
||||||
public function getRebroadcastsAbsolute()
|
public function getRebroadcastsAbsolute()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT date(starts) "
|
$sql = "SELECT date(starts) "
|
||||||
."FROM cc_show_instances "
|
."FROM cc_show_instances "
|
||||||
|
@ -207,7 +207,7 @@ class Show {
|
||||||
$sql = "SELECT date(DATE '$baseDate' + day_offset::INTERVAL) as start_date, start_time FROM cc_show_rebroadcast "
|
$sql = "SELECT date(DATE '$baseDate' + day_offset::INTERVAL) as start_date, start_time FROM cc_show_rebroadcast "
|
||||||
."WHERE show_id = $showId "
|
."WHERE show_id = $showId "
|
||||||
."ORDER BY start_date";
|
."ORDER BY start_date";
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,20 +217,20 @@ class Show {
|
||||||
* "x days" and time would HH:MM:SS
|
* "x days" and time would HH:MM:SS
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* array of associate arrays containing "day_offset" and "start_time"
|
* array of associate arrays containing "day_offset" and "start_time"
|
||||||
*/
|
*/
|
||||||
public function getRebroadcastsRelative()
|
public function getRebroadcastsRelative()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT day_offset, start_time FROM cc_show_rebroadcast "
|
$sql = "SELECT day_offset, start_time FROM cc_show_rebroadcast "
|
||||||
."WHERE show_id = $showId "
|
."WHERE show_id = $showId "
|
||||||
."ORDER BY day_offset";
|
."ORDER BY day_offset";
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the current show is set to repeat
|
* Check whether the current show is set to repeat
|
||||||
* repeating shows.
|
* repeating shows.
|
||||||
|
@ -249,11 +249,11 @@ class Show {
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the repeat type of the show. Show can have repeat
|
* Get the repeat type of the show. Show can have repeat
|
||||||
* type of "weekly", "bi-weekly" and "monthly". These values
|
* type of "weekly", "bi-weekly" and "monthly". These values
|
||||||
* are represented by 0, 1, and 2 respectively.
|
* are represented by 0, 1, and 2 respectively.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
* Return the integer corresponding to the repeat type.
|
* Return the integer corresponding to the repeat type.
|
||||||
|
@ -279,14 +279,14 @@ class Show {
|
||||||
*/
|
*/
|
||||||
public function getRepeatingEndDate(){
|
public function getRepeatingEndDate(){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT last_show FROM cc_show_days"
|
$sql = "SELECT last_show FROM cc_show_days"
|
||||||
." WHERE show_id = $showId"
|
." WHERE show_id = $showId"
|
||||||
." ORDER BY last_show DESC";
|
." ORDER BY last_show DESC";
|
||||||
|
|
||||||
$endDate = $CC_DBC->GetOne($sql);
|
$endDate = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if (is_null($endDate)){
|
if (is_null($endDate)){
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
@ -309,8 +309,8 @@ class Show {
|
||||||
$sql = "DELETE FROM cc_show_instances"
|
$sql = "DELETE FROM cc_show_instances"
|
||||||
." WHERE starts > TIMESTAMP '$timestamp'"
|
." WHERE starts > TIMESTAMP '$timestamp'"
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -331,8 +331,8 @@ class Show {
|
||||||
." WHERE date(starts) > DATE '$p_date'"
|
." WHERE date(starts) > DATE '$p_date'"
|
||||||
." AND starts > TIMESTAMP '$timestamp'"
|
." AND starts > TIMESTAMP '$timestamp'"
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -353,8 +353,8 @@ class Show {
|
||||||
." WHERE date(starts) < DATE '$p_date'"
|
." WHERE date(starts) < DATE '$p_date'"
|
||||||
." AND starts > TIMESTAMP '$timestamp'"
|
." AND starts > TIMESTAMP '$timestamp'"
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -362,17 +362,17 @@ class Show {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* The start date in the format YYYY-MM-DD
|
* The start date in the format YYYY-MM-DD
|
||||||
*/
|
*/
|
||||||
public function getStartDate(){
|
public function getStartDate(){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT first_show FROM cc_show_days"
|
$sql = "SELECT first_show FROM cc_show_days"
|
||||||
." WHERE show_id = $showId"
|
." WHERE show_id = $showId"
|
||||||
." ORDER BY first_show";
|
." ORDER BY first_show";
|
||||||
|
|
||||||
$firstDate = $CC_DBC->GetOne($sql);
|
$firstDate = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if (is_null($firstDate)){
|
if (is_null($firstDate)){
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
@ -385,16 +385,16 @@ class Show {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* The start time in the format HH:MM:SS
|
* The start time in the format HH:MM:SS
|
||||||
*/
|
*/
|
||||||
public function getStartTime(){
|
public function getStartTime(){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT start_time FROM cc_show_days"
|
$sql = "SELECT start_time FROM cc_show_days"
|
||||||
." WHERE show_id = $showId";
|
." WHERE show_id = $showId";
|
||||||
|
|
||||||
$startTime = $CC_DBC->GetOne($sql);
|
$startTime = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if (is_null($startTime)){
|
if (is_null($startTime)){
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
@ -407,18 +407,18 @@ class Show {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* A simple array containing all future instance ID's
|
* A simple array containing all future instance ID's
|
||||||
*/
|
*/
|
||||||
public function getAllFutureInstanceIds(){
|
public function getAllFutureInstanceIds(){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$date = new DateHelper;
|
$date = new DateHelper;
|
||||||
$timestamp = $date->getTimestamp();
|
$timestamp = $date->getTimestamp();
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT id from cc_show_instances"
|
$sql = "SELECT id from cc_show_instances"
|
||||||
." WHERE show_id = $showId"
|
." WHERE show_id = $showId"
|
||||||
." AND starts > TIMESTAMP '$timestamp'";
|
." AND starts > TIMESTAMP '$timestamp'";
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
$instance_ids = array();
|
$instance_ids = array();
|
||||||
|
@ -427,36 +427,36 @@ class Show {
|
||||||
}
|
}
|
||||||
return $instance_ids;
|
return $instance_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateDurationTime($p_data){
|
private function updateDurationTime($p_data){
|
||||||
//need to update cc_show_instances, cc_show_days
|
//need to update cc_show_instances, cc_show_days
|
||||||
|
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$date = new DateHelper;
|
$date = new DateHelper;
|
||||||
$timestamp = $date->getTimestamp();
|
$timestamp = $date->getTimestamp();
|
||||||
|
|
||||||
$sql = "UPDATE cc_show_days "
|
$sql = "UPDATE cc_show_days "
|
||||||
."SET duration = '$p_data[add_show_duration]' "
|
."SET duration = '$p_data[add_show_duration]' "
|
||||||
."WHERE show_id = $p_data[add_show_id]";
|
."WHERE show_id = $p_data[add_show_id]";
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
|
||||||
$sql = "UPDATE cc_show_instances "
|
$sql = "UPDATE cc_show_instances "
|
||||||
."SET ends = starts + INTERVAL '$p_data[add_show_duration]' "
|
."SET ends = starts + INTERVAL '$p_data[add_show_duration]' "
|
||||||
."WHERE show_id = $p_data[add_show_id] "
|
."WHERE show_id = $p_data[add_show_id] "
|
||||||
."AND starts > TIMESTAMP '$timestamp'";
|
."AND starts > TIMESTAMP '$timestamp'";
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateStartDateTime($p_data, $p_endDate){
|
private function updateStartDateTime($p_data, $p_endDate){
|
||||||
//need to update cc_schedule, cc_show_instances, cc_show_days
|
//need to update cc_schedule, cc_show_instances, cc_show_days
|
||||||
|
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$date = new DateHelper;
|
$date = new DateHelper;
|
||||||
$timestamp = $date->getTimestamp();
|
$timestamp = $date->getTimestamp();
|
||||||
|
|
||||||
$sql = "UPDATE cc_show_days "
|
$sql = "UPDATE cc_show_days "
|
||||||
."SET start_time = TIME '$p_data[add_show_start_time]', "
|
."SET start_time = TIME '$p_data[add_show_start_time]', "
|
||||||
."first_show = DATE '$p_data[add_show_start_date]', ";
|
."first_show = DATE '$p_data[add_show_start_date]', ";
|
||||||
|
@ -467,7 +467,7 @@ class Show {
|
||||||
}
|
}
|
||||||
$sql .= "WHERE show_id = $p_data[add_show_id]";
|
$sql .= "WHERE show_id = $p_data[add_show_id]";
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
|
||||||
$oldStartDateTimeEpoch = strtotime($this->getStartDate()." ".$this->getStartTime());
|
$oldStartDateTimeEpoch = strtotime($this->getStartDate()." ".$this->getStartTime());
|
||||||
$newStartDateTimeEpoch = strtotime($p_data['add_show_start_date']." ".$p_data['add_show_start_time']);
|
$newStartDateTimeEpoch = strtotime($p_data['add_show_start_date']." ".$p_data['add_show_start_time']);
|
||||||
$diff = $newStartDateTimeEpoch - $oldStartDateTimeEpoch;
|
$diff = $newStartDateTimeEpoch - $oldStartDateTimeEpoch;
|
||||||
|
@ -476,61 +476,61 @@ class Show {
|
||||||
."SET starts = starts + INTERVAL '$diff sec', "
|
."SET starts = starts + INTERVAL '$diff sec', "
|
||||||
."ends = ends + INTERVAL '$diff sec' "
|
."ends = ends + INTERVAL '$diff sec' "
|
||||||
."WHERE show_id = $p_data[add_show_id] "
|
."WHERE show_id = $p_data[add_show_id] "
|
||||||
."AND starts > TIMESTAMP '$timestamp'";
|
."AND starts > TIMESTAMP '$timestamp'";
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
|
||||||
$showInstanceIds = $this->getAllFutureInstanceIds();
|
$showInstanceIds = $this->getAllFutureInstanceIds();
|
||||||
if (count($showInstanceIds) > 0 && $diff != 0){
|
if (count($showInstanceIds) > 0 && $diff != 0){
|
||||||
$showIdsImploded = implode(",", $showInstanceIds);
|
$showIdsImploded = implode(",", $showInstanceIds);
|
||||||
$sql = "UPDATE cc_schedule "
|
$sql = "UPDATE cc_schedule "
|
||||||
."SET starts = starts + INTERVAL '$diff sec', "
|
."SET starts = starts + INTERVAL '$diff sec', "
|
||||||
."ends = ends + INTERVAL '$diff sec' "
|
."ends = ends + INTERVAL '$diff sec' "
|
||||||
."WHERE instance_id IN ($showIdsImploded)";
|
."WHERE instance_id IN ($showIdsImploded)";
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDuration(){
|
public function getDuration(){
|
||||||
$showDay = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->findOne();
|
$showDay = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->findOne();
|
||||||
return $showDay->getDbDuration();
|
return $showDay->getDbDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShowDays(){
|
public function getShowDays(){
|
||||||
$showDays = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->find();
|
$showDays = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->find();
|
||||||
|
|
||||||
$days = array();
|
$days = array();
|
||||||
foreach ($showDays as $showDay){
|
foreach ($showDays as $showDay){
|
||||||
array_push($days, $showDay->getDbDay());
|
array_push($days, $showDay->getDbDay());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $days;
|
return $days;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasInstance(){
|
public function hasInstance(){
|
||||||
return (!is_null($this->getInstance()));
|
return (!is_null($this->getInstance()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInstance(){
|
public function getInstance(){
|
||||||
$showInstances = CcShowInstancesQuery::create()->filterByDbShowId($this->getId())->findOne();
|
$showInstances = CcShowInstancesQuery::create()->filterByDbShowId($this->getId())->findOne();
|
||||||
return $showInstances;
|
return $showInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasInstanceOnDate($p_timestamp){
|
public function hasInstanceOnDate($p_timestamp){
|
||||||
return (!is_null($this->getInstanceOnDate($p_timestamp)));
|
return (!is_null($this->getInstanceOnDate($p_timestamp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInstanceOnDate($p_timestamp){
|
public function getInstanceOnDate($p_timestamp){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT id FROM cc_show_instances"
|
$sql = "SELECT id FROM cc_show_instances"
|
||||||
." WHERE date(starts) = date(TIMESTAMP '$p_timestamp') "
|
." WHERE date(starts) = date(TIMESTAMP '$p_timestamp') "
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$row = $CC_DBC->GetOne($sql);
|
$row = $CC_DBC->GetOne($sql);
|
||||||
return CcShowInstancesQuery::create()->findPk($row);
|
return CcShowInstancesQuery::create()->findPk($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deletePossiblyInvalidInstances($p_data, $p_show, $p_endDate, $isRecorded, $repeatType)
|
public static function deletePossiblyInvalidInstances($p_data, $p_show, $p_endDate, $isRecorded, $repeatType)
|
||||||
{
|
{
|
||||||
if ($p_data['add_show_repeats'] != $p_show->isRepeating()
|
if ($p_data['add_show_repeats'] != $p_show->isRepeating()
|
||||||
|
@ -543,17 +543,17 @@ class Show {
|
||||||
//duration has changed
|
//duration has changed
|
||||||
$p_show->updateDurationTime($p_data);
|
$p_show->updateDurationTime($p_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($p_data['add_show_repeats']){
|
if ($p_data['add_show_repeats']){
|
||||||
if ($p_data['add_show_start_date'] != $p_show->getStartDate()
|
if ($p_data['add_show_start_date'] != $p_show->getStartDate()
|
||||||
|| $p_data['add_show_start_time'] != $p_show->getStartTime()){
|
|| $p_data['add_show_start_time'] != $p_show->getStartTime()){
|
||||||
//start date/time has changed
|
//start date/time has changed
|
||||||
|
|
||||||
$newDate = strtotime($p_data['add_show_start_date']);
|
$newDate = strtotime($p_data['add_show_start_date']);
|
||||||
$oldDate = strtotime($p_show->getStartDate());
|
$oldDate = strtotime($p_show->getStartDate());
|
||||||
if ($newDate > $oldDate){
|
if ($newDate > $oldDate){
|
||||||
$p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
|
$p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$p_show->updateStartDateTime($p_data, $p_endDate);
|
$p_show->updateStartDateTime($p_data, $p_endDate);
|
||||||
}
|
}
|
||||||
|
@ -574,16 +574,16 @@ class Show {
|
||||||
} else {
|
} else {
|
||||||
$repeatingDaysChanged = true;
|
$repeatingDaysChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($repeatingDaysChanged){
|
if ($repeatingDaysChanged){
|
||||||
$daysRemoved = array_diff($showDaysArray, $p_data['add_show_day_check']);
|
$daysRemoved = array_diff($showDaysArray, $p_data['add_show_day_check']);
|
||||||
|
|
||||||
if (count($daysRemoved) > 0){
|
if (count($daysRemoved) > 0){
|
||||||
$p_show->removeUncheckedDaysInstances($daysRemoved);
|
$p_show->removeUncheckedDaysInstances($daysRemoved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if end date for the repeat option has changed. If so, need to take care
|
//Check if end date for the repeat option has changed. If so, need to take care
|
||||||
//of deleting possible invalid Show Instances.
|
//of deleting possible invalid Show Instances.
|
||||||
if ((strlen($p_show->getRepeatingEndDate()) == 0) == $p_data['add_show_no_end']){
|
if ((strlen($p_show->getRepeatingEndDate()) == 0) == $p_data['add_show_no_end']){
|
||||||
|
@ -595,7 +595,7 @@ class Show {
|
||||||
}
|
}
|
||||||
if ($p_show->getRepeatingEndDate() != $p_data['add_show_end_date']){
|
if ($p_show->getRepeatingEndDate() != $p_data['add_show_end_date']){
|
||||||
//end date was changed.
|
//end date was changed.
|
||||||
|
|
||||||
$newDate = strtotime($p_data['add_show_end_date']);
|
$newDate = strtotime($p_data['add_show_end_date']);
|
||||||
$oldDate = strtotime($p_show->getRepeatingEndDate());
|
$oldDate = strtotime($p_show->getRepeatingEndDate());
|
||||||
if ($newDate < $oldDate){
|
if ($newDate < $oldDate){
|
||||||
|
@ -664,17 +664,17 @@ class Show {
|
||||||
$show = new Show($showId);
|
$show = new Show($showId);
|
||||||
|
|
||||||
$isRecorded = ($data['add_show_record']) ? 1 : 0;
|
$isRecorded = ($data['add_show_record']) ? 1 : 0;
|
||||||
|
|
||||||
if ($data['add_show_id'] != -1){
|
if ($data['add_show_id'] != -1){
|
||||||
Show::deletePossiblyInvalidInstances($data, $show, $endDate, $isRecorded, $repeatType);
|
Show::deletePossiblyInvalidInstances($data, $show, $endDate, $isRecorded, $repeatType);
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if we are adding or updating a show, and if updating
|
//check if we are adding or updating a show, and if updating
|
||||||
//erase all the show's show_days information first.
|
//erase all the show's show_days information first.
|
||||||
if ($data['add_show_id'] != -1){
|
if ($data['add_show_id'] != -1){
|
||||||
CcShowDaysQuery::create()->filterByDbShowId($data['add_show_id'])->delete();
|
CcShowDaysQuery::create()->filterByDbShowId($data['add_show_id'])->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
//don't set day for monthly repeat type, it's invalid.
|
//don't set day for monthly repeat type, it's invalid.
|
||||||
if ($data['add_show_repeats'] && $data['add_show_repeat_type'] == 2){
|
if ($data['add_show_repeats'] && $data['add_show_repeat_type'] == 2){
|
||||||
$showDay = new CcShowDays();
|
$showDay = new CcShowDays();
|
||||||
|
@ -855,7 +855,7 @@ class Show {
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||||
$end = $CC_DBC->GetOne($sql);
|
$end = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
$show = new Show($show_id);
|
$show = new Show($show_id);
|
||||||
if ($show->hasInstance()){
|
if ($show->hasInstance()){
|
||||||
$ccShowInstance = $show->getInstance();
|
$ccShowInstance = $show->getInstance();
|
||||||
|
@ -864,7 +864,7 @@ class Show {
|
||||||
$ccShowInstance = new CcShowInstances();
|
$ccShowInstance = new CcShowInstances();
|
||||||
$newInstance = true;
|
$newInstance = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ccShowInstance->setDbShowId($show_id);
|
$ccShowInstance->setDbShowId($show_id);
|
||||||
$ccShowInstance->setDbStarts($start);
|
$ccShowInstance->setDbStarts($start);
|
||||||
$ccShowInstance->setDbEnds($end);
|
$ccShowInstance->setDbEnds($end);
|
||||||
|
@ -877,7 +877,7 @@ class Show {
|
||||||
if (!$newInstance){
|
if (!$newInstance){
|
||||||
$showInstance->correctScheduleStartTimes();
|
$showInstance->correctScheduleStartTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
|
@ -927,7 +927,7 @@ class Show {
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||||
$end = $CC_DBC->GetOne($sql);
|
$end = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if ($show->hasInstanceOnDate($start)){
|
if ($show->hasInstanceOnDate($start)){
|
||||||
$ccShowInstance = $show->getInstanceOnDate($start);
|
$ccShowInstance = $show->getInstanceOnDate($start);
|
||||||
$newInstance = false;
|
$newInstance = false;
|
||||||
|
@ -1100,7 +1100,7 @@ class Show {
|
||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function makeFullCalendarEvent($show, $options=array())
|
private static function makeFullCalendarEvent($show, $options=array())
|
||||||
{
|
{
|
||||||
$event = array();
|
$event = array();
|
||||||
|
|
||||||
|
@ -1125,7 +1125,7 @@ class Show {
|
||||||
}
|
}
|
||||||
if($show["background_color"] != "") {
|
if($show["background_color"] != "") {
|
||||||
$event["color"] = "#".$show["background_color"];
|
$event["color"] = "#".$show["background_color"];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($options as $key=>$value) {
|
foreach($options as $key=>$value) {
|
||||||
$event[$key] = $value;
|
$event[$key] = $value;
|
||||||
|
@ -1138,12 +1138,12 @@ class Show {
|
||||||
$explode = explode(" ", $p_timestamp);
|
$explode = explode(" ", $p_timestamp);
|
||||||
return $explode[0];
|
return $explode[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getTimeFromTimestamp($p_timestamp){
|
public static function getTimeFromTimestamp($p_timestamp){
|
||||||
$explode = explode(" ", $p_timestamp);
|
$explode = explode(" ", $p_timestamp);
|
||||||
return $explode[1];
|
return $explode[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function formats a time by removing seconds
|
* This function formats a time by removing seconds
|
||||||
*
|
*
|
||||||
|
@ -1240,7 +1240,7 @@ class ShowInstance {
|
||||||
|
|
||||||
return $showStartExplode[1];
|
return $showStartExplode[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSoundCloudFileId($p_soundcloud_id)
|
public function setSoundCloudFileId($p_soundcloud_id)
|
||||||
{
|
{
|
||||||
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);
|
||||||
|
@ -1270,7 +1270,7 @@ class ShowInstance {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,7 +1299,7 @@ class ShowInstance {
|
||||||
|
|
||||||
public function correctScheduleStartTimes(){
|
public function correctScheduleStartTimes(){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$instance_id = $this->getShowInstanceId();
|
$instance_id = $this->getShowInstanceId();
|
||||||
$sql = "SELECT starts from cc_schedule"
|
$sql = "SELECT starts from cc_schedule"
|
||||||
." WHERE instance_id = $instance_id"
|
." WHERE instance_id = $instance_id"
|
||||||
|
@ -1307,7 +1307,7 @@ class ShowInstance {
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$scheduleStarts = $CC_DBC->GetOne($sql);
|
$scheduleStarts = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if (!is_null($scheduleStarts)){
|
if (!is_null($scheduleStarts)){
|
||||||
$scheduleStartsEpoch = strtotime($scheduleStarts);
|
$scheduleStartsEpoch = strtotime($scheduleStarts);
|
||||||
$showStartsEpoch = strtotime($this->getShowStart());
|
$showStartsEpoch = strtotime($this->getShowStart());
|
||||||
|
@ -1318,7 +1318,7 @@ class ShowInstance {
|
||||||
$sql = "UPDATE cc_schedule"
|
$sql = "UPDATE cc_schedule"
|
||||||
." SET starts = starts + INTERVAL '$diff' second,"
|
." SET starts = starts + INTERVAL '$diff' second,"
|
||||||
." ends = ends + INTERVAL '$diff' second"
|
." ends = ends + INTERVAL '$diff' second"
|
||||||
." WHERE instance_id = $instance_id";
|
." WHERE instance_id = $instance_id";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
@ -1553,7 +1553,7 @@ class ShowInstance {
|
||||||
$start_timestamp = $this->getShowStart();
|
$start_timestamp = $this->getShowStart();
|
||||||
$end_timestamp = $this->getShowEnd();
|
$end_timestamp = $this->getShowEnd();
|
||||||
$time_filled = $this->getTimeScheduled();
|
$time_filled = $this->getTimeScheduled();
|
||||||
|
|
||||||
$s_epoch = strtotime($start_timestamp);
|
$s_epoch = strtotime($start_timestamp);
|
||||||
$e_epoch = strtotime($end_timestamp);
|
$e_epoch = strtotime($end_timestamp);
|
||||||
$i_epoch = Schedule::WallTimeToMillisecs($time_filled) / 1000;
|
$i_epoch = Schedule::WallTimeToMillisecs($time_filled) / 1000;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require_once("Playlist.php");
|
require_once("Playlist.php");
|
||||||
require_once(dirname(__FILE__)."/../../library/getid3/var/getid3.php");
|
require_once("getid3/var/getid3.php");
|
||||||
require_once("Schedule.php");
|
require_once("Schedule.php");
|
||||||
|
|
||||||
class Metadata {
|
class Metadata {
|
||||||
|
@ -730,7 +730,6 @@ class StoredFile {
|
||||||
return $storedFile;
|
return $storedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance of StoreFile object and recall existing file
|
* Create instance of StoreFile object and recall existing file
|
||||||
* by gunid.
|
* by gunid.
|
||||||
|
@ -757,6 +756,14 @@ class StoredFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function GetAll()
|
||||||
|
{
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
$sql = "SELECT * FROM ".$CC_CONFIG["filesTable"];
|
||||||
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the location to store the file.
|
* Generate the location to store the file.
|
||||||
* It creates the subdirectory if needed.
|
* It creates the subdirectory if needed.
|
||||||
|
@ -1163,10 +1170,7 @@ class StoredFile {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError("StoredFile::deleteFile: unlink failed ({$this->filepath})");
|
||||||
"StoredFile::deleteFile: unlink failed ({$this->filepath})",
|
|
||||||
GBERR_FILEIO
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1205,6 +1209,34 @@ class StoredFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function deleteById($p_id)
|
||||||
|
{
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
if (!is_numeric($p_id)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
$sql = "DELETE FROM ".$CC_CONFIG["filesTable"]." WHERE id=$p_id";
|
||||||
|
|
||||||
|
$res = $CC_DBC->query($sql);
|
||||||
|
if (PEAR::isError($res)) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function deleteAll()
|
||||||
|
{
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
$files = StoredFile::getAll();
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$media = StoredFile::Recall($file["id"]);
|
||||||
|
$result = $media->delete();
|
||||||
|
if (PEAR::isError($result)) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of playlist objects that this file is a part of.
|
* Returns an array of playlist objects that this file is a part of.
|
||||||
* @return array
|
* @return array
|
||||||
|
@ -1555,7 +1587,7 @@ class StoredFile {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function searchPlaylistsForSchedule($datatables)
|
public static function searchPlaylistsForSchedule($datatables)
|
||||||
{
|
{
|
||||||
$fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id";
|
$fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id";
|
||||||
//$datatables["optWhere"][] = "INTERVAL '{$time_remaining}' > INTERVAL '00:00:00'";
|
//$datatables["optWhere"][] = "INTERVAL '{$time_remaining}' > INTERVAL '00:00:00'";
|
||||||
|
|
|
@ -31,12 +31,12 @@
|
||||||
<label class="optional"><?php echo $this->element->getElement('streamFormat')->getLabel() ?></label>
|
<label class="optional"><?php echo $this->element->getElement('streamFormat')->getLabel() ?></label>
|
||||||
</dt>
|
</dt>
|
||||||
<dd id="streamFormat-element" class="block-display radio-inline-list">
|
<dd id="streamFormat-element" class="block-display radio-inline-list">
|
||||||
<?php $i=0;
|
<?php $i=0;
|
||||||
$value = $this->element->getElement('streamFormat')->getValue();
|
$value = $this->element->getElement('streamFormat')->getValue();
|
||||||
?>
|
?>
|
||||||
<?php foreach ($this->element->getElement('streamFormat')->getMultiOptions() as $radio) : ?>
|
<?php foreach ($this->element->getElement('streamFormat')->getMultiOptions() as $radio) : ?>
|
||||||
<label for="streamFormat-<?php echo $i ?>">
|
<label for="streamFormat-<?php echo $i ?>">
|
||||||
<input type="radio" value="<?php echo $i ?>" id="streamFormat-<?php echo $i ?>" name="streamFormat" <?php if($i == $value){echo 'checked="checked"';}?>/>
|
<input type="radio" value="<?php echo $i ?>" id="streamFormat-<?php echo $i ?>" name="streamFormat" <?php if($i == $value){echo 'checked="checked"';}?> >
|
||||||
<?php echo $radio ?>
|
<?php echo $radio ?>
|
||||||
</input>
|
</input>
|
||||||
</label>
|
</label>
|
||||||
|
@ -54,12 +54,12 @@
|
||||||
<label class="optional"><?php echo $this->element->getElement('thirdPartyApi')->getLabel() ?></label>
|
<label class="optional"><?php echo $this->element->getElement('thirdPartyApi')->getLabel() ?></label>
|
||||||
</dt>
|
</dt>
|
||||||
<dd id="thirdPartyApi-element" class="block-display radio-inline-list">
|
<dd id="thirdPartyApi-element" class="block-display radio-inline-list">
|
||||||
<?php $i=0;
|
<?php $i=0;
|
||||||
$value = $this->element->getElement('thirdPartyApi')->getValue();
|
$value = $this->element->getElement('thirdPartyApi')->getValue();
|
||||||
?>
|
?>
|
||||||
<?php foreach ($this->element->getElement('thirdPartyApi')->getMultiOptions() as $radio) : ?>
|
<?php foreach ($this->element->getElement('thirdPartyApi')->getMultiOptions() as $radio) : ?>
|
||||||
<label for="thirdPartyApi-<?php echo $i ?>">
|
<label for="thirdPartyApi-<?php echo $i ?>">
|
||||||
<input type="radio" value="<?php echo $i ?>" id="thirdPartyApi-<?php echo $i ?>" name="thirdPartyApi" <?php if($i == $value){echo 'checked="checked"';}?> />
|
<input type="radio" value="<?php echo $i ?>" id="thirdPartyApi-<?php echo $i ?>" name="thirdPartyApi" <?php if($i == $value){echo 'checked="checked"';}?>>
|
||||||
<?php echo $radio ?>
|
<?php echo $radio ?>
|
||||||
</input>
|
</input>
|
||||||
</label>
|
</label>
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
<li><?php echo $error; ?></li>
|
<li><?php echo $error; ?></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<?php
|
<?php
|
||||||
echo this->entries;
|
echo $this->entries;
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -104,15 +104,17 @@ function setAddShowEvents() {
|
||||||
|
|
||||||
form.find("#add_show_rebroadcast").click(function(){
|
form.find("#add_show_rebroadcast").click(function(){
|
||||||
$(this).blur();
|
$(this).blur();
|
||||||
if($(this).attr('checked') && !form.find("#add_show_repeats").attr('checked')) {
|
if(form.find("#add_show_record").attr('checked')){
|
||||||
form.find("#add_show_rebroadcast_absolute").show();
|
if($(this).attr('checked') && !form.find("#add_show_repeats").attr('checked')) {
|
||||||
}
|
form.find("#add_show_rebroadcast_absolute").show();
|
||||||
else if($(this).attr('checked') && form.find("#add_show_repeats").attr('checked')) {
|
}
|
||||||
form.find("#add_show_rebroadcast_relative").show();
|
else if($(this).attr('checked') && form.find("#add_show_repeats").attr('checked')) {
|
||||||
}
|
form.find("#add_show_rebroadcast_relative").show();
|
||||||
else {
|
}
|
||||||
form.find("#schedule-record-rebroadcast > fieldset:not(:first-child)").hide();
|
else {
|
||||||
}
|
form.find("#schedule-record-rebroadcast > fieldset:not(:first-child)").hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
form.find("#add_show_repeat_type").change(function(){
|
form.find("#add_show_repeat_type").change(function(){
|
||||||
|
|
|
@ -228,7 +228,7 @@ function buildScheduleDialog(json){
|
||||||
|
|
||||||
dialog.dialog({
|
dialog.dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
title: 'Schedule Playlist',
|
title: 'Schedule Media',
|
||||||
width: 1100,
|
width: 1100,
|
||||||
height: 550,
|
height: 550,
|
||||||
modal: true,
|
modal: true,
|
||||||
|
|
|
@ -51,10 +51,10 @@ else if (!isset($opts->p) && !isset($opts->o)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo "* Creating INI files".PHP_EOL;
|
$overwrite = true;
|
||||||
AirtimeIni::CreateIniFiles();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($overwrite) {
|
if ($overwrite) {
|
||||||
echo "* Creating INI files".PHP_EOL;
|
echo "* Creating INI files".PHP_EOL;
|
||||||
AirtimeIni::CreateIniFiles();
|
AirtimeIni::CreateIniFiles();
|
||||||
|
@ -90,6 +90,8 @@ AirtimeInstall::ChangeDirOwnerToWebserver($CC_CONFIG["storageDir"]);
|
||||||
|
|
||||||
AirtimeInstall::CreateSymlinksToUtils();
|
AirtimeInstall::CreateSymlinksToUtils();
|
||||||
|
|
||||||
|
AirtimeInstall::CreateZendPhpLogFile();
|
||||||
|
|
||||||
echo PHP_EOL."*** Pypo Installation ***".PHP_EOL;
|
echo PHP_EOL."*** Pypo Installation ***".PHP_EOL;
|
||||||
system("python ".__DIR__."/../python_apps/pypo/install/pypo-install.py");
|
system("python ".__DIR__."/../python_apps/pypo/install/pypo-install.py");
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ system($command);
|
||||||
|
|
||||||
AirtimeInstall::RemoveSymlinks();
|
AirtimeInstall::RemoveSymlinks();
|
||||||
AirtimeInstall::UninstallBinaries();
|
AirtimeInstall::UninstallBinaries();
|
||||||
|
AirtimeInstall::RemoveLogDirectories();
|
||||||
|
|
||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
echo "****************************** Uninstall Complete ******************************".PHP_EOL;
|
echo "****************************** Uninstall Complete ******************************".PHP_EOL;
|
||||||
|
|
|
@ -14,13 +14,16 @@ require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
|
||||||
AirtimeInstall::ExitIfNotRoot();
|
AirtimeInstall::ExitIfNotRoot();
|
||||||
AirtimeInstall::DbConnect(true);
|
AirtimeInstall::DbConnect(true);
|
||||||
|
|
||||||
if(AirtimeInstall::DbTableExists('cc_show_rebroadcast') === true) {
|
$version = AirtimeInstall::GetAirtimeVersion();
|
||||||
$version = "1.7.0";
|
if (!$version){
|
||||||
echo "Airtime Version: ".$version." ".PHP_EOL;
|
if(AirtimeInstall::DbTableExists('cc_show_rebroadcast') === true) {
|
||||||
}
|
$version = "1.7.0";
|
||||||
else {
|
echo "Airtime Version: ".$version." ".PHP_EOL;
|
||||||
$version = "1.6";
|
}
|
||||||
echo "Airtime Version: ".$version." ".PHP_EOL;
|
else {
|
||||||
|
$version = "1.6";
|
||||||
|
echo "Airtime Version: ".$version." ".PHP_EOL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "******************************** Update Begin *********************************".PHP_EOL;
|
echo "******************************** Update Begin *********************************".PHP_EOL;
|
||||||
|
@ -31,6 +34,9 @@ if(strcmp($version, "1.7.0") < 0) {
|
||||||
if(strcmp($version, "1.8.0") < 0) {
|
if(strcmp($version, "1.8.0") < 0) {
|
||||||
system("php ".__DIR__."/upgrades/airtime-1.8/airtime-upgrade.php");
|
system("php ".__DIR__."/upgrades/airtime-1.8/airtime-upgrade.php");
|
||||||
}
|
}
|
||||||
|
if (strcmp($version, "1.9.0") < 0){
|
||||||
|
system("php ".__DIR__."/upgrades/airtime-1.9/airtime-upgrade.php");
|
||||||
|
}
|
||||||
|
|
||||||
AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION);
|
AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ class AirtimeInstall
|
||||||
const CONF_DIR_BINARIES = "/usr/lib/airtime";
|
const CONF_DIR_BINARIES = "/usr/lib/airtime";
|
||||||
const CONF_DIR_STORAGE = "/srv/airtime";
|
const CONF_DIR_STORAGE = "/srv/airtime";
|
||||||
const CONF_DIR_WWW = "/var/www/airtime";
|
const CONF_DIR_WWW = "/var/www/airtime";
|
||||||
|
const CONF_DIR_LOG = "/var/log/airtime";
|
||||||
|
|
||||||
public static function GetAirtimeSrcDir()
|
public static function GetAirtimeSrcDir()
|
||||||
{
|
{
|
||||||
|
@ -321,4 +322,28 @@ class AirtimeInstall
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 RemoveLogDirectories(){
|
||||||
|
$path = AirtimeInstall::CONF_DIR_LOG;
|
||||||
|
echo "* Removing logs directory ".$path.PHP_EOL;
|
||||||
|
|
||||||
|
exec("rm -rf $path");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?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 __DIR__.'/../../../airtime_mvc/application/configs/conf.php';
|
||||||
|
require_once(dirname(__FILE__).'/../../include/AirtimeInstall.php');
|
||||||
|
require_once(dirname(__FILE__).'/../../include/AirtimeIni.php');
|
||||||
|
|
||||||
|
AirtimeInstall::CreateZendPhpLogFile();
|
|
@ -180,7 +180,7 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
print 'Unable to get Airtime version number.'
|
print 'Unable to get Airtime version number.'
|
||||||
print
|
print
|
||||||
return False
|
return False
|
||||||
elif (version[0:4] != "1.8."):
|
elif (version[0:4] != "1.9."):
|
||||||
if (verbose):
|
if (verbose):
|
||||||
print 'Airtime version: ' + str(version)
|
print 'Airtime version: ' + str(version)
|
||||||
print 'pypo not compatible with this version of Airtime.'
|
print 'pypo not compatible with this version of Airtime.'
|
||||||
|
|
|
@ -38,10 +38,7 @@ try:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
os.system("python /usr/bin/airtime-pypo-stop")
|
os.system("python /usr/bin/airtime-pypo-stop")
|
||||||
|
|
||||||
print "Removing log directories"
|
|
||||||
remove_path(config["log_base_dir"])
|
|
||||||
|
|
||||||
print "Removing cache directories"
|
print "Removing cache directories"
|
||||||
remove_path(config["cache_base_dir"])
|
remove_path(config["cache_base_dir"])
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
api_client = "airtime"
|
||||||
|
|
||||||
|
# Hostname
|
||||||
|
base_url = 'localhost'
|
||||||
|
base_port = 80
|
||||||
|
|
||||||
|
# where the binary files live
|
||||||
|
bin_dir = '/usr/lib/airtime/media-monitor'
|
||||||
|
|
||||||
|
# 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%%'
|
|
@ -0,0 +1,52 @@
|
||||||
|
import os
|
||||||
|
import pyinotify
|
||||||
|
from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent
|
||||||
|
|
||||||
|
# configure logging
|
||||||
|
try:
|
||||||
|
logging.config.fileConfig("logging.cfg")
|
||||||
|
except Exception, e:
|
||||||
|
print 'Error configuring logging: ', e
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
# loading config file
|
||||||
|
try:
|
||||||
|
config = ConfigObj('/etc/airtime/recorder.cfg')
|
||||||
|
except Exception, e:
|
||||||
|
print 'Error loading config file: ', e
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
# watched events
|
||||||
|
mask = pyinotify.ALL_EVENTS
|
||||||
|
|
||||||
|
wm = WatchManager()
|
||||||
|
wdd = wm.add_watch('/srv/airtime/stor', mask, rec=True)
|
||||||
|
|
||||||
|
class PTmp(ProcessEvent):
|
||||||
|
def process_IN_CREATE(self, event):
|
||||||
|
if event.dir :
|
||||||
|
global wm
|
||||||
|
wdd = wm.add_watch(event.pathname, mask, rec=True)
|
||||||
|
#print wdd.keys()
|
||||||
|
|
||||||
|
print "%s: %s" % (event.maskname, os.path.join(event.path, event.name))
|
||||||
|
|
||||||
|
def process_IN_MODIFY(self, event):
|
||||||
|
if not event.dir :
|
||||||
|
print event.path
|
||||||
|
|
||||||
|
print "%s: %s" % (event.maskname, os.path.join(event.path, event.name))
|
||||||
|
|
||||||
|
def process_default(self, event):
|
||||||
|
print "%s: %s" % (event.maskname, os.path.join(event.path, event.name))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
try:
|
||||||
|
notifier = Notifier(wm, PTmp(), read_freq=2, timeout=1)
|
||||||
|
notifier.coalesce_events()
|
||||||
|
notifier.loop()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
notifier.stop()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
[loggers]
|
||||||
|
keys=root
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys=consoleHandler
|
||||||
|
|
||||||
|
[formatters]
|
||||||
|
keys=simpleFormatter
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level=DEBUG
|
||||||
|
handlers=consoleHandler
|
||||||
|
|
||||||
|
[handler_consoleHandler]
|
||||||
|
class=StreamHandler
|
||||||
|
level=DEBUG
|
||||||
|
formatter=simpleFormatter
|
||||||
|
args=(sys.stdout,)
|
||||||
|
|
||||||
|
[formatter_simpleFormatter]
|
||||||
|
format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s
|
||||||
|
datefmt=
|
|
@ -21,6 +21,14 @@
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# This script cleans audio files in the Airtime storageServer.
|
# This script cleans audio files in Airtime.
|
||||||
|
#
|
||||||
|
# Absolute path to this script
|
||||||
|
SCRIPT=`readlink -f $0`
|
||||||
|
# Absolute path this script is in
|
||||||
|
SCRIPTPATH=`dirname $SCRIPT`
|
||||||
|
|
||||||
php -q airtime-clean-storage.php "$@" || exit 1
|
invokePwd=$PWD
|
||||||
|
cd $SCRIPTPATH
|
||||||
|
|
||||||
|
php -q airtime-clean-storage.php "$@" || exit 1
|
||||||
|
|
|
@ -9,117 +9,111 @@ if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_include_path('/var/www/airtime/library' . PATH_SEPARATOR . get_include_path());
|
||||||
|
set_include_path('/var/www/airtime/application/models' . PATH_SEPARATOR . get_include_path());
|
||||||
require_once('/var/www/airtime/application/configs/conf.php');
|
require_once('/var/www/airtime/application/configs/conf.php');
|
||||||
//require_once('/var/www/airtime/install/installInit.php');
|
|
||||||
require_once('/var/www/airtime/application/models/StoredFile.php');
|
require_once('/var/www/airtime/application/models/StoredFile.php');
|
||||||
require_once('DB.php');
|
require_once('DB.php');
|
||||||
|
require_once 'propel/runtime/lib/Propel.php';
|
||||||
|
Propel::init('/var/www/airtime/application/configs/airtime-conf.php');
|
||||||
|
|
||||||
function printUsage() {
|
|
||||||
|
|
||||||
global $CC_CONFIG;
|
/**
|
||||||
|
*
|
||||||
echo "Usage:\n";
|
* Look through all the files in the database and remove the rows
|
||||||
echo " ./airtime-clean-storage [OPTION] \n";
|
* that have no associated file.
|
||||||
echo "\n";
|
*
|
||||||
echo "Options:\n";
|
* @return int
|
||||||
echo " -c, --clean Removes all broken links from the storage server\n";
|
* The total number of files that were missing.
|
||||||
echo " and empties all missing file information from the database.\n";
|
*/
|
||||||
echo "\n";
|
function airtime_clean_files() {
|
||||||
echo " -e, --empty Removes all files from the storage server \n";
|
$count = 0;
|
||||||
echo " and empties all relevant information from the database.\n\n";
|
$files = StoredFile::GetAll();
|
||||||
echo "Storage server: ". realpath($CC_CONFIG["storageDir"]) ."\n\n\n";
|
foreach ($files as $file) {
|
||||||
}
|
if (($file["ftype"] == "audioclip") && !@file_exists($file["filepath"])) {
|
||||||
|
echo " * Removing metadata for id ".$file["id"].":".PHP_EOL;
|
||||||
function airtime_clean_files($p_path) {
|
echo " * File path: ".$file["filepath"].PHP_EOL;
|
||||||
if (!empty($p_path) && (strlen($p_path) > 4)) {
|
echo " * Track title: ".$file["track_title"].PHP_EOL;
|
||||||
list($dirList,$fileList) = File_Find::maptree($p_path);
|
echo " * Artist: ".$file["artist_name"].PHP_EOL;
|
||||||
|
echo " * Album: ".$file["album_title"].PHP_EOL;
|
||||||
$array_mus;
|
StoredFile::deleteById($file["id"]);
|
||||||
foreach ($fileList as $filepath) {
|
$count++;
|
||||||
|
|
||||||
if (@substr($filepath, strlen($filepath) - 3) != "xml") {
|
|
||||||
$array_mus[] = $filepath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($array_mus as $audio_file) {
|
|
||||||
|
|
||||||
if (@is_link($audio_file) && !@stat($audio_file)) {
|
|
||||||
|
|
||||||
//filesystem clean up.
|
|
||||||
@unlink($audio_file);
|
|
||||||
echo "unlinked $audio_file\n";
|
|
||||||
@unlink($audio_file . ".xml");
|
|
||||||
echo "unlinked " . $audio_file . ".xml\n";
|
|
||||||
@rmdir(@dirname($audio_file));
|
|
||||||
echo "removed dir " . @dirname($audio_file) . "\n";
|
|
||||||
|
|
||||||
//database clean up.
|
|
||||||
$stored_audio_file = StoredFile::RecallByGunid(@basename($audio_file));
|
|
||||||
$stored_audio_file->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function airtime_remove_files($p_path) {
|
|
||||||
|
|
||||||
if (!empty($p_path) && (strlen($p_path) > 4)) {
|
|
||||||
list($dirList,$fileList) = File_Find::maptree($p_path);
|
|
||||||
|
|
||||||
foreach ($fileList as $filepath) {
|
|
||||||
echo " * Removing $filepath\n";
|
|
||||||
@unlink($filepath);
|
|
||||||
echo "done.\n";
|
|
||||||
}
|
|
||||||
foreach ($dirList as $dirpath) {
|
|
||||||
echo " * Removing $dirpath\n";
|
|
||||||
@rmdir($dirpath);
|
|
||||||
echo "done.\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
function airtime_empty_db($db) {
|
function airtime_empty_db($db)
|
||||||
global $CC_CONFIG;
|
{
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
if (!PEAR::isError($db)) {
|
// NOTE: order matter here.
|
||||||
if (AirtimeInstall::DbTableExists($CC_CONFIG['filesTable'])) {
|
echo " * Clearing schedule table...".PHP_EOL;
|
||||||
echo " * Deleting from database table ".$CC_CONFIG['filesTable']."\n";
|
Schedule::deleteAll();
|
||||||
$sql = "DELETE FROM ".$CC_CONFIG['filesTable'];
|
|
||||||
AirtimeInstall::InstallQuery($sql, false);
|
// Ugly hack
|
||||||
}
|
echo " * Resetting show instance times to zero...".PHP_EOL;
|
||||||
else {
|
$sql = "UPDATE cc_show_instances SET time_filled='00:00:00'";
|
||||||
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
|
$CC_DBC->query($sql);
|
||||||
}
|
|
||||||
|
echo " * Clearing playlist table...".PHP_EOL;
|
||||||
|
Playlist::deleteAll();
|
||||||
|
|
||||||
|
echo " * Clearing files table...".PHP_EOL;
|
||||||
|
$result = StoredFile::deleteAll();
|
||||||
|
if (PEAR::isError($result)) {
|
||||||
|
echo $result->getMessage().PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
|
||||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
require_once('Zend/Loader/Autoloader.php');
|
||||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
$autoloader = Zend_Loader_Autoloader::getInstance();
|
||||||
|
|
||||||
if ($argc != 2){
|
try {
|
||||||
printUsage();
|
$opts = new Zend_Console_Getopt(
|
||||||
|
array(
|
||||||
|
'help|h' => 'Displays usage information.',
|
||||||
|
'clean|c' => 'Removes all audio file metadata from the database that does not have a matching file in the filesystem.',
|
||||||
|
'empty|e' => 'Removes all files and playlists from Airtime.'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$opts->parse();
|
||||||
|
} catch (Zend_Console_Getopt_Exception $e) {
|
||||||
|
exit($e->getMessage() .PHP_EOL. $e->getUsageMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($opts->h)) {
|
||||||
|
echo PHP_EOL;
|
||||||
|
echo $opts->getUsageMessage();
|
||||||
|
echo "Storage directory: ". realpath($CC_CONFIG["storageDir"]).PHP_EOL.PHP_EOL;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need to check that we are superuser before running this.
|
||||||
|
if (exec("whoami") != "root") {
|
||||||
|
echo PHP_EOL."You must be root to use this script.".PHP_EOL.PHP_EOL;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($argv[1]){
|
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||||
|
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
case '-e':
|
|
||||||
case '--empty':
|
|
||||||
airtime_empty_db($CC_DBC);
|
|
||||||
airtime_remove_files($CC_CONFIG['storageDir']);
|
|
||||||
break;
|
|
||||||
case '-c':
|
|
||||||
case '--clean':
|
|
||||||
airtime_clean_files($CC_CONFIG['storageDir']);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printUsage();
|
|
||||||
|
|
||||||
|
if (isset($opts->e)) {
|
||||||
|
echo PHP_EOL;
|
||||||
|
airtime_empty_db($CC_DBC);
|
||||||
|
echo "Done.".PHP_EOL.PHP_EOL;
|
||||||
|
} elseif (isset($opts->c)) {
|
||||||
|
$count = airtime_clean_files($CC_CONFIG['storageDir']);
|
||||||
|
if ($count == 0) {
|
||||||
|
echo PHP_EOL."All file metadata in the database is linked to a real file. Nothing to be done.".PHP_EOL.PHP_EOL;
|
||||||
|
} else {
|
||||||
|
echo PHP_EOL."Total rows removed: $count".PHP_EOL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo PHP_EOL;
|
||||||
|
echo $opts->getUsageMessage();
|
||||||
|
echo "Storage directory: ". realpath($CC_CONFIG["storageDir"]).PHP_EOL.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# This script imports audio files to the Airtime storageServer.
|
# This script imports audio files into Airtime.
|
||||||
#
|
#
|
||||||
# To get usage help, try the -h option
|
# To get usage help, try the -h option
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
|
@ -10,14 +10,16 @@
|
||||||
ini_set('memory_limit', '128M');
|
ini_set('memory_limit', '128M');
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
set_error_handler("camp_import_error_handler", E_ALL & !E_NOTICE);
|
set_error_handler("import_error_handler", E_ALL & !E_NOTICE);
|
||||||
|
|
||||||
|
set_include_path('/var/www/airtime/library' . PATH_SEPARATOR . get_include_path());
|
||||||
|
|
||||||
require_once("/var/www/airtime/application/configs/conf.php");
|
require_once("/var/www/airtime/application/configs/conf.php");
|
||||||
require_once("/var/www/airtime/application/models/StoredFile.php");
|
require_once("/var/www/airtime/application/models/StoredFile.php");
|
||||||
require_once('DB.php');
|
require_once('DB.php');
|
||||||
require_once('Console/Getopt.php');
|
require_once('Console/Getopt.php');
|
||||||
|
|
||||||
function camp_import_error_handler()
|
function import_error_handler()
|
||||||
{
|
{
|
||||||
echo var_dump(debug_backtrace());
|
echo var_dump(debug_backtrace());
|
||||||
exit();
|
exit();
|
||||||
|
@ -92,7 +94,7 @@ function import_err($p_pearErrorObj, $txt='')
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function camp_import_audio_file($p_filepath, $p_importMode = null, $p_testOnly = false)
|
function import_audio_file($p_filepath, $p_importMode = null, $p_testOnly = false)
|
||||||
{
|
{
|
||||||
global $STORAGE_SERVER_PATH;
|
global $STORAGE_SERVER_PATH;
|
||||||
global $g_fileCount;
|
global $g_fileCount;
|
||||||
|
@ -126,7 +128,7 @@ function camp_import_audio_file($p_filepath, $p_importMode = null, $p_testOnly =
|
||||||
while (false !== ($file = readdir($d))) {
|
while (false !== ($file = readdir($d))) {
|
||||||
if ($file != "." && $file != "..") {
|
if ($file != "." && $file != "..") {
|
||||||
$path = "$p_filepath/$file";
|
$path = "$p_filepath/$file";
|
||||||
camp_import_audio_file($path, $p_importMode, $p_testOnly);
|
import_audio_file($path, $p_importMode, $p_testOnly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($d);
|
closedir($d);
|
||||||
|
@ -241,7 +243,7 @@ if ($DEBUG_IMPORT) {
|
||||||
$dsn = $CC_CONFIG['dsn'];
|
$dsn = $CC_CONFIG['dsn'];
|
||||||
}
|
}
|
||||||
//PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
//PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "camp_import_error_handler");
|
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "import_error_handler");
|
||||||
$CC_DBC = DB::connect($dsn, TRUE);
|
$CC_DBC = DB::connect($dsn, TRUE);
|
||||||
if (PEAR::isError($CC_DBC)) {
|
if (PEAR::isError($CC_DBC)) {
|
||||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||||
|
@ -301,13 +303,14 @@ if (is_null($importMode)) {
|
||||||
|
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
|
||||||
if (!is_writable($CC_CONFIG["storageDir"])) {
|
if ( ($importMode == "copy") && !is_writable($CC_CONFIG["storageDir"])) {
|
||||||
echo "ERROR: You do not have write permissions to the directory you are trying to import to:\n " . $CC_CONFIG["storageDir"] . "\n\n";
|
echo "ERROR: You do not have write permissions to the directory you are trying to import to:\n " . $CC_CONFIG["storageDir"] . "\n\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
global $g_fileCount;
|
global $g_fileCount;
|
||||||
global $g_duplicates;
|
global $g_duplicates;
|
||||||
|
$g_fileCount = 0;
|
||||||
if (is_array($files)) {
|
if (is_array($files)) {
|
||||||
foreach ($files as $filepath) {
|
foreach ($files as $filepath) {
|
||||||
// absolute path
|
// absolute path
|
||||||
|
@ -323,7 +326,7 @@ if (is_array($files)) {
|
||||||
echo "ERROR: I cant find the given file: $filepath\n\n";
|
echo "ERROR: I cant find the given file: $filepath\n\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
camp_import_audio_file($fullPath, $importMode, $testonly);
|
import_audio_file($fullPath, $importMode, $testonly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$end = intval(date('U'));
|
$end = intval(date('U'));
|
||||||
|
@ -336,7 +339,9 @@ if ($time > 0) {
|
||||||
|
|
||||||
echo "==========================================================================\n";
|
echo "==========================================================================\n";
|
||||||
echo " *** Import mode: $importMode\n";
|
echo " *** Import mode: $importMode\n";
|
||||||
echo " *** Destination folder: ".$CC_CONFIG['storageDir']."\n";
|
if ($importMode == "copy") {
|
||||||
|
echo " *** Destination folder: ".$CC_CONFIG['storageDir']."\n";
|
||||||
|
}
|
||||||
echo " *** Files imported: $g_fileCount\n";
|
echo " *** Files imported: $g_fileCount\n";
|
||||||
echo " *** Duplicate files (not imported): $g_duplicates\n";
|
echo " *** Duplicate files (not imported): $g_duplicates\n";
|
||||||
if ($g_errors > 0) {
|
if ($g_errors > 0) {
|
||||||
|
|
Loading…
Reference in New Issue