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

Conflicts:
	install/airtime-install.php
This commit is contained in:
Paul Baranowski 2011-05-30 15:35:38 -04:00
commit d8f4c3e616
23 changed files with 473 additions and 234 deletions

View File

@ -16,6 +16,7 @@ Highlights:
- In the "Add Media" page, the "start upload" button vanished after upload. Now it remains there after upload so it is possible to upload again.
- When canceling a playing show, the currently playing audio file still showed as playing. This has been fixed.
- Audio files greater than 100MB were not being played.
- Fixed uploading audio on Chrome 11 and higher
1.8.1 - May 2, 2011

View File

@ -1,6 +1,6 @@
<?php
define('AIRTIME_VERSION', '1.8.2');
define('AIRTIME_VERSION', '1.9.0-devel');
define('AIRTIME_COPYRIGHT_DATE', '2010-2011');
define('AIRTIME_REST_VERSION', '1.1');

View File

@ -19,16 +19,16 @@ class ApiController extends Zend_Controller_Action
// action body
}
/**
* Returns Airtime version. i.e "1.7.0 alpha"
*
* First checks to ensure the correct API key was
* supplied, then returns AIRTIME_VERSION as defined
* in application/conf.php
*
* @return void
*
*/
/**
* Returns Airtime version. i.e "1.7.0 alpha"
*
* First checks to ensure the correct API key was
* supplied, then returns AIRTIME_VERSION as defined
* in application/conf.php
*
* @return void
*
*/
public function versionAction()
{
global $CC_CONFIG;
@ -40,20 +40,20 @@ class ApiController extends Zend_Controller_Action
$api_key = $this->_getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
}
$jsonStr = json_encode(array("version"=>AIRTIME_VERSION));
echo $jsonStr;
}
/**
* Allows remote client to download requested media file.
*
* @return void
* The given value increased by the increment amount.
*/
/**
* Allows remote client to download requested media file.
*
* @return void
* The given value increased by the increment amount.
*/
public function getMediaAction()
{
global $CC_CONFIG;
@ -67,9 +67,9 @@ class ApiController extends Zend_Controller_Action
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
}
$filename = $this->_getParam("file");
@ -80,39 +80,40 @@ class ApiController extends Zend_Controller_Action
$filepath = $media->getRealFilePath();
if(!is_file($filepath))
{
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
//print 'Resource in database, but not in storage. Sorry.';
exit;
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
//print 'Resource in database, but not in storage. Sorry.';
exit;
}
// !! binary mode !!
$fp = fopen($filepath, 'rb');
// possibly use fileinfo module here in the future.
// http://www.php.net/manual/en/book.fileinfo.php
// possibly use fileinfo module here in the future.
// http://www.php.net/manual/en/book.fileinfo.php
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if ($ext == "ogg")
header("Content-Type: audio/ogg");
else if ($ext == "mp3")
header("Content-Type: audio/mpeg");
if ($download){
header('Content-Disposition: attachment; filename="'.$media->getName().'"');
}
header("Content-Length: " . filesize($filepath));
//flush the file contents 16 KBytes at a time. In the future we may
//want to use the "X-Sendfile header" method instead.
while (!feof($fp)) {
echo fread($fp, 64*1024);
ob_end_flush();
if ($download){
header('Content-Disposition: attachment; filename="'.$media->getName().'"');
}
header("Content-Length: " . filesize($filepath));
// !! binary mode !!
$fp = fopen($filepath, 'rb');
//We can have multiple levels of output buffering. Need to
//keep looping until all have been disabled!!!
//http://www.php.net/manual/en/function.ob-end-flush.php
while (@ob_end_flush());
fpassthru($fp);
fclose($fp);
return;
}
}
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
exit;
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
exit;
}
public function liveInfoAction()
@ -261,9 +262,9 @@ class ApiController extends Zend_Controller_Action
$api_key = $this->_getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
}
$today_timestamp = date("Y-m-d H:i:s");
@ -288,9 +289,9 @@ class ApiController extends Zend_Controller_Action
$api_key = $this->_getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
}
$upload_dir = ini_get("upload_tmp_dir");
@ -350,9 +351,9 @@ class ApiController extends Zend_Controller_Action
$api_key = $this->_getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
}
$md = $this->_getParam('md');

View File

@ -227,7 +227,7 @@ class ScheduleController extends Zend_Controller_Action
'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content');
}
if (strtotime($show->getShowEnd()) <= strtotime($today_timestamp)
if (strtotime($show->getShowEnd()) <= strtotime($today_timestamp)
&& is_null($show->getSoundCloudFileId())
&& Application_Model_Preference::GetDoSoundCloudUpload()) {
$menu[] = array('action' => array('type' => 'fn',
@ -405,9 +405,9 @@ class ScheduleController extends Zend_Controller_Action
if(!$user->isAdmin()) {
return;
}
$showInstanceId = $this->_getParam('id');
$formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
@ -438,7 +438,7 @@ class ScheduleController extends Zend_Controller_Action
$showInstance = new ShowInstance($showInstanceId);
$show = new Show($showInstance->getShowId());
$formWhat->populate(array('add_show_id' => $show->getId(),
'add_show_name' => $show->getName(),
'add_show_url' => $show->getUrl(),
@ -455,10 +455,14 @@ class ScheduleController extends Zend_Controller_Action
foreach($showDays as $showDay){
array_push($days, $showDay->getDbDay());
}
$displayedEndDate = new DateTime($show->getRepeatingEndDate());
$displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively.
$displayedEndDate = $displayedEndDate->format("Y-m-d");
$formRepeats->populate(array('add_show_repeat_type' => $show->getRepeatType(),
'add_show_day_check' => $days,
'add_show_end_date' => $show->getRepeatingEndDate(),
'add_show_end_date' => $displayedEndDate,
'add_show_no_end' => ($show->getRepeatingEndDate() == '')));
$formRecord->populate(array('add_show_record' => $show->isRecorded(),
@ -475,7 +479,7 @@ class ScheduleController extends Zend_Controller_Action
$rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Show::removeSecondsFromTime($rebroadcast['start_time']);
$i++;
}
$formRebroadcast->populate($rebroadcastFormValues);
$formRebroadcast->populate($rebroadcastFormValues);
$rebroadcastsAbsolute = $show->getRebroadcastsAbsolute();
$rebroadcastAbsoluteFormValues = array();
@ -497,7 +501,7 @@ class ScheduleController extends Zend_Controller_Action
$formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(),
'add_show_color' => $show->getColor()));
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
$this->view->entries = 5;
}
@ -543,7 +547,7 @@ class ScheduleController extends Zend_Controller_Action
foreach($js as $j){
$data[$j["name"]] = $j["value"];
}
$data['add_show_hosts'] = $this->_getParam('hosts');
$data['add_show_day_check'] = $this->_getParam('days');
@ -586,7 +590,7 @@ class ScheduleController extends Zend_Controller_Action
}
if($data["add_show_repeats"]) {
$repeats = $formRepeats->isValid($data);
if($repeats) {
$repeats = $formRepeats->checkReliantFields($data);
@ -596,7 +600,7 @@ class ScheduleController extends Zend_Controller_Action
//make it valid, results don't matter anyways.
$rebroadAb = 1;
if ($data["add_show_rebroadcast"]) {
if ($data["add_show_rebroadcast"]) {
$rebroad = $formRebroadcast->isValid($data);
if($rebroad) {
$rebroad = $formRebroadcast->checkReliantFields($data);
@ -612,7 +616,7 @@ class ScheduleController extends Zend_Controller_Action
$repeats = 1;
$rebroad = 1;
if ($data["add_show_rebroadcast"]) {
if ($data["add_show_rebroadcast"]) {
$rebroadAb = $formAbsoluteRebroadcast->isValid($data);
if($rebroadAb) {
$rebroadAb = $formAbsoluteRebroadcast->checkReliantFields($data);
@ -634,10 +638,10 @@ class ScheduleController extends Zend_Controller_Action
if ($data['add_show_id'] != -1){
$show = new Show($data['add_show_id']);
$data['add_show_record'] = $show->isRecorded();
$record = $formRecord->isValid($data);
$record = $formRecord->isValid($data);
$formRecord->getElement('add_show_record')->setOptions(array('disabled' => true));
} else {
$record = $formRecord->isValid($data);
$record = $formRecord->isValid($data);
}
if ($what && $when && $repeats && $who && $style && $record && $rebroadAb && $rebroad) {
@ -650,7 +654,7 @@ class ScheduleController extends Zend_Controller_Action
//send back a new form for the user.
$formWhat->reset();
$formWhat->populate(array('add_show_id' => '-1'));
$formWho->reset();
$formWhen->reset();
$formWhen->populate(array('add_show_start_date' => date("Y-m-d"),
@ -704,10 +708,10 @@ class ScheduleController extends Zend_Controller_Action
$show->deleteShow();
}
}
public function contentContextMenuAction(){
global $CC_CONFIG;
$id = $this->_getParam('id');
$params = '/format/json/id/#id#/';

View File

@ -43,9 +43,7 @@ class Application_Form_EditAudioMD extends Zend_Form
'required' => true,
'class' => 'input_text',
'filters' => array('StringTrim'),
'validators' => array(
'NotEmpty',
)
'validators' => array('NotEmpty')
));
// Add album field
@ -55,11 +53,12 @@ class Application_Form_EditAudioMD extends Zend_Form
'filters' => array('StringTrim')
));
// Add mood field
// Add track number field
$this->addElement('text', 'track_number', array(
'label' => 'Track:',
'class' => 'input_text',
'filters' => array('StringTrim')
'filters' => array('StringTrim'),
'validators' => array('Int')
));
// Add genre field
@ -78,7 +77,7 @@ class Application_Form_EditAudioMD extends Zend_Form
array('date', false, array('YYYY-MM-DD')),
array('date', false, array('YYYY-MM')),
array('date', false, array('YYYY'))
)
)
));
// Add label field
@ -135,9 +134,9 @@ class Application_Form_EditAudioMD extends Zend_Form
'ignore' => true,
'class' => 'ui-button ui-state-default',
'label' => 'Submit',
'decorators' => array(
'decorators' => array(
'ViewHelper'
)
)
));
// Add the submit button
@ -146,13 +145,13 @@ class Application_Form_EditAudioMD extends Zend_Form
'class' => 'ui-button ui-state-default ui-button-text-only md-cancel',
'label' => 'Cancel',
'onclick' => 'javascript:document.location="/Library"',
'decorators' => array(
'decorators' => array(
'ViewHelper'
)
));
$this->addDisplayGroup(array('submit', 'cancel'), 'submitButtons', array(
'decorators' => array(
$this->addDisplayGroup(array('submit', 'cancel'), 'submitButtons', array(
'decorators' => array(
'FormElements',
'DtDdWrapper'
)

View File

@ -87,8 +87,9 @@ class Application_Model_Dashboard
if (count($row) == 0){
return null;
} else {
//should never reach here. Doesnt make sense to have
//a schedule item not within a show_instance.
return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
"starts"=>$row[0]["starts"],
"ends"=>$row[0]["ends"]);
}
} else {
if (count($row) == 0){

View File

@ -320,7 +320,7 @@ class Show {
* @param string $p_date
* The date which to delete after
*/
public function removeAllInstancesAfterDate($p_date){
public function removeAllInstancesFromDate($p_date){
global $CC_DBC;
$date = new DateHelper;
@ -328,7 +328,7 @@ class Show {
$showId = $this->getId();
$sql = "DELETE FROM cc_show_instances "
." WHERE date(starts) > DATE '$p_date'"
." WHERE date(starts) >= DATE '$p_date'"
." AND starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId";
@ -590,7 +590,7 @@ class Show {
//show "Never Ends" option was toggled.
if ($p_data['add_show_no_end']){
} else {
$p_show->removeAllInstancesAfterDate($p_endDate);
$p_show->removeAllInstancesFromDate($p_endDate);
}
}
if ($p_show->getRepeatingEndDate() != $p_data['add_show_end_date']){
@ -599,7 +599,7 @@ class Show {
$newDate = strtotime($p_data['add_show_end_date']);
$oldDate = strtotime($p_show->getRepeatingEndDate());
if ($newDate < $oldDate){
$p_show->removeAllInstancesAfterDate($p_endDate);
$p_show->removeAllInstancesFromDate($p_endDate);
}
}
}
@ -608,7 +608,7 @@ class Show {
/**
* Create a show.
*
* Note: end dates are non inclusive.
* Note: end dates are inclusive.
*
* @param array $data
* @return int
@ -624,7 +624,6 @@ class Show {
if ($data['add_show_no_end']) {
$endDate = NULL;
//$data['add_show_repeats'] = 1;
}
else if ($data['add_show_repeats']) {
$sql = "SELECT date '{$data['add_show_end_date']}' + INTERVAL '1 day' ";
@ -703,7 +702,7 @@ class Show {
$start = $data['add_show_start_date'];
}
if (strtotime($start) < strtotime($endDate) || is_null($endDate)) {
if (strtotime($start) <= strtotime($endDate) || is_null($endDate)) {
$showDay = new CcShowDays();
$showDay->setDbFirstShow($start);
$showDay->setDbLastShow($endDate);
@ -921,7 +920,7 @@ class Show {
$rebroadcasts = $CC_DBC->GetAll($sql);
$show = new Show($show_id);
while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
while(strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
$start = $next_date;
@ -1179,7 +1178,7 @@ class ShowInstance {
{
$this->_instanceId = $instanceId;
$this->_showInstance = CcShowInstancesQuery::create()->findPK($instanceId);
if (is_null($this->_showInstance)){
throw new Exception();
}
@ -1630,32 +1629,32 @@ class ShowInstance {
return $items;
}
public static function GetShowsInstancesIdsInRange($p_timeNow, $p_start, $p_end)
{
global $CC_DBC;
$sql = "SELECT id FROM cc_show_instances AS si "
$sql = "SELECT id FROM cc_show_instances AS si "
."WHERE ("
."(si.starts < TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' "
."AND si.ends > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds') "
."OR (si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' "
."OR (si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' "
."AND si.ends < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') "
."OR (si.starts < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds' "
."AND si.ends > TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') "
.") "
." ORDER BY si.starts";
$rows = $CC_DBC->GetAll($sql);
return $rows;
}
public function getScheduleItemsInRange($timeNow, $start, $end)
{
global $CC_DBC, $CC_CONFIG;
$instanceId = $this->_instanceId;
$sql = "SELECT"
." si.starts as show_starts,"
." si.ends as show_ends,"
@ -1687,30 +1686,30 @@ class ShowInstance {
return $CC_DBC->GetAll($sql);
}
public function getLastAudioItemEnd(){
global $CC_DBC;
$sql = "SELECT ends FROM cc_schedule "
."WHERE instance_id = {$this->_instanceId} "
."ORDER BY ends DESC "
."LIMIT 1";
return $CC_DBC->GetOne($sql);
return $CC_DBC->GetOne($sql);
}
public function getShowEndGapTime(){
$showEnd = $this->getShowEnd();
$lastItemEnd = $this->getLastAudioItemEnd();
if (is_null($lastItemEnd)){
$lastItemEnd = $this->getShowStart();
}
$diff = strtotime($showEnd) - strtotime($lastItemEnd);
return ($diff < 0) ? 0 : $diff;
return ($diff < 0) ? 0 : $diff;
}
public static function GetLastShowInstance($p_timeNow){

View File

@ -546,10 +546,12 @@ class StoredFile {
$data = array();
foreach ($p_values as $category => $value) {
$escapedValue = pg_escape_string($value);
$columnName = $category;
if (!is_null($columnName)) {
$data[] = "$columnName='$escapedValue'";
if (isset($value) && ($value != '')) {
$escapedValue = pg_escape_string($value);
$columnName = $category;
if (!is_null($columnName)) {
$data[] = "$columnName='$escapedValue'";
}
}
}
@ -734,7 +736,14 @@ class StoredFile {
$storedFile->mtime = $row['mtime'];
$storedFile->md5 = $row['md5'];
$storedFile->filepath = $row['filepath'];
$storedFile->exists = TRUE;
if(file_exists($row['filepath'])) {
$storedFile->exists = true;
}
else {
$storedFile->exists = false;
}
$storedFile->setFormat($row['ftype']);
return $storedFile;
}
@ -867,7 +876,7 @@ class StoredFile {
* local path
* @return TRUE|PEAR_Error
*/
public function replaceFile($p_localFilePath)
public function replaceFile($p_localFilePath, $p_copyMedia=TRUE)
{
// Dont do anything if the source and destination files are
// the same.
@ -881,7 +890,7 @@ class StoredFile {
return $r;
}
}
return $this->addFile($p_localFilePath);
return $this->addFile($p_localFilePath, $p_copyMedia);
}
@ -1783,8 +1792,17 @@ class StoredFile {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
}
else {
$duplicateName = $duplicate->getMetadataValue(UI_MDATA_KEY_TITLE);
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named ' . $duplicateName . ' already exists in the storage server."}}');
if (file_exists($duplicate->getRealFilePath())) {
$duplicateName = $duplicate->getMetadataValue(UI_MDATA_KEY_TITLE);
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named ' . $duplicateName . ' already exists in the storage server."}}');
}
else {
$res = $duplicate->replaceFile($audio_file);
if (PEAR::isError($res)) {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
}
return $duplicate;
}
}
}

View File

@ -74,7 +74,8 @@ function addLibraryItemEvents() {
$('#library_display tr[id ^= "au"]')
.draggable({
helper: 'clone'
helper: 'clone',
cursor: 'pointer'
});
$('#library_display tbody tr')

View File

@ -171,11 +171,17 @@ function createDataGrid(){
var gapTime = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex]]._aData[4];
var hours = parseInt( gapTime / 3600 ) % 24;
var minutes = parseInt( gapTime / 60 ) % 60;
var seconds = gapTime % 60;
var gapTimeFormat = (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds);
var nGroup = document.createElement('tr');
var nCell = document.createElement('td');
nCell.colSpan = iColspan;
nCell.className = "gap";
nCell.innerHTML = "Gap until show end: " + gapTime + " seconds";
nCell.innerHTML = "Gap until show end: " + gapTimeFormat + " seconds";
nGroup.appendChild(nCell);
nTrs[i].parentNode.replaceChild(nGroup, nTrs[i]);
} else if ( sType.indexOf("r") != -1 ){

View File

@ -26,11 +26,11 @@ function endDpSelect(dateText, inst) {
function createDateInput(el, onSelect) {
var date;
el.datepicker({
minDate: new Date(),
onSelect: onSelect,
dateFormat: 'yy-mm-dd'
dateFormat: 'yy-mm-dd'
});
}
@ -46,13 +46,23 @@ function findHosts(request, callback) {
url = "/User/get-hosts";
search = request.term;
$.post(url,
{format: "json", term: search},
$.post(url,
{format: "json", term: search},
function(json) {
callback(json.hosts);
});
}
function beginEditShow(data){
$("#add-show-form")
.empty()
.append(data.newForm);
removeAddShowButton();
setAddShowEvents();
openAddShowForm();
}
function setAddShowEvents() {
@ -155,24 +165,24 @@ function setAddShowEvents() {
});
form.find("#add_show_duration").timepicker({
amPmText: ['', ''],
defaultTime: '01:00'
defaultTime: '01:00'
});
form.find('input[name^="add_show_rebroadcast_date_absolute"]').datepicker({
minDate: new Date(),
dateFormat: 'yy-mm-dd'
dateFormat: 'yy-mm-dd'
});
form.find('input[name^="add_show_rebroadcast_time"]').timepicker({
amPmText: ['', ''],
defaultTime: ''
defaultTime: ''
});
form.find(".add_absolute_rebroadcast_day").click(function(){
var li = $(this).parent().find("ul.formrow-repeat > li:visible:last").next();
var li = $(this).parent().find("ul.formrow-repeat > li:visible:last").next();
li.show();
li = li.next();
if(li.length === 0) {
if(li.length === 0) {
$(this).hide();
}
});
@ -207,11 +217,11 @@ function setAddShowEvents() {
list.next().show();
});
form.find("#add_show_hosts_autocomplete").autocomplete({
source: findHosts,
select: autoSelect,
delay: 200
delay: 200
});
form.find("#schedule-show-style input").ColorPicker({
@ -246,7 +256,7 @@ function setAddShowEvents() {
.append(json.form);
setAddShowEvents();
});
});
makeAddShowButton();
});
@ -255,7 +265,7 @@ function setAddShowEvents() {
var addShowButton = $(this);
if (!addShowButton.hasClass("disabled")){
addShowButton.addClass("disabled");
}
}
else {
return;
}
@ -290,7 +300,7 @@ function setAddShowEvents() {
$("#add_show_end_date").val(end_date);
$("#add_show_start_date").val(start_date);
showErrorSections();
showErrorSections();
}
else {
$("#add-show-form")

View File

@ -46,16 +46,6 @@ function removeAddShowButton(){
span.remove();
}
function beginEditShow(data){
$("#add-show-form")
.empty()
.append(data.newForm);
removeAddShowButton();
setAddShowEvents();
openAddShowForm();
}
function makeTimeStamp(date){
var sy, sm, sd, h, m, s, timestamp;
sy = date.getFullYear();
@ -70,7 +60,7 @@ function makeTimeStamp(date){
}
function dayClick(date, allDay, jsEvent, view) {
var now, today, selected, chosenDate, chosenTime;
var now, today, selected, chosenDate, chosenTime;
now = new Date();
@ -125,7 +115,7 @@ function dayClick(date, allDay, jsEvent, view) {
$("#add_show_end_date").val(chosenDate);
$("#add_show_start_time").val(chosenTime);
$("#schedule-show-when").show();
openAddShowForm();
}
}
@ -155,7 +145,7 @@ function viewDisplay( view ) {
//re-initialize calendar with new slotmin options
$(calendarEl)
.fullCalendar('destroy')
.fullCalendar(opt)
.fullCalendar(opt)
.fullCalendar( 'gotoDate', date );
});
@ -176,7 +166,7 @@ function viewDisplay( view ) {
}
}
function eventRender(event, element, view) {
function eventRender(event, element, view) {
//only put progress bar on shows that aren't being recorded.
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 0) {
@ -198,29 +188,29 @@ function eventRender(event, element, view) {
//record icon (only if not on soundcloud, will always be true for future events)
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 1 && event.soundcloud_id === -1) {
$(element).find(".fc-event-time").before('<span class="small-icon recording"></span>');
}
if(view.name === 'month' && event.record === 1 && event.soundcloud_id === -1) {
$(element).find(".fc-event-title").after('<span class="small-icon recording"></span>');
}
//rebroadcast icon
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.rebroadcast === 1) {
$(element).find(".fc-event-time").before('<span class="small-icon rebroadcast"></span>');
}
if(view.name === 'month' && event.rebroadcast === 1) {
$(element).find(".fc-event-title").after('<span class="small-icon rebroadcast"></span>');
}
//soundcloud icon
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.soundcloud_id !== -1 && event.record === 1) {
$(element).find(".fc-event-time").before('<span class="small-icon soundcloud"></span>');
}
if(view.name === 'month' && event.soundcloud_id !== -1 && event.record === 1) {
$(element).find(".fc-event-title").after('<span class="small-icon soundcloud"></span>');
}
}
@ -228,9 +218,9 @@ function eventRender(event, element, view) {
function eventAfterRender( event, element, view ) {
$(element)
.jjmenu("click",
[{get:"/Schedule/make-context-menu/format/json/id/#id#"}],
{id: event.id},
.jjmenu("click",
[{get:"/Schedule/make-context-menu/format/json/id/#id#"}],
{id: event.id},
{xposition: "mouse", yposition: "mouse"});
}
@ -239,7 +229,7 @@ function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui
url = '/Schedule/move-show/format/json';
$.post(url,
$.post(url,
{day: dayDelta, min: minuteDelta, showInstanceId: event.id},
function(json){
if(json.error) {
@ -249,19 +239,19 @@ function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui
});
}
function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) {
function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) {
var url;
url = '/Schedule/resize-show/format/json';
$.post(url,
$.post(url,
{day: dayDelta, min: minuteDelta, showInstanceId: event.id},
function(json){
if(json.error) {
alert(json.error);
revertFunc();
}
scheduleRefetchEvents();
});
}
@ -273,7 +263,7 @@ function getFullCalendarEvents(start, end, callback) {
end_date = makeTimeStamp(end);
url = '/Schedule/event-feed';
var d = new Date();
$.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,10 @@
* @package Airtime
* @copyright 2011 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*
* Checks if a previous version of Airtime is currently installed, upgrades Airtime if so.
* Performs a new install (new configs, database install) if a version of Airtime is not found
* If the current version is found to be installed the User is presented with the help menu and can choose -r to reinstall.
*/
set_include_path(__DIR__.'/../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
@ -16,7 +20,7 @@ require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.
AirtimeInstall::ExitIfNotRoot();
$newInstall = false;
$version = AirtimeInstall::CheckForVersionBeforeInstall();
$version = AirtimeInstall::GetVersionInstalled();
require_once('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance();
@ -42,27 +46,29 @@ if (isset($opts->h)) {
exit;
}
//the current version exists.
if(isset($version) && $version != false && $version == AIRTIME_VERSION && !isset($opts->r)) {
echo "Airtime $version is already installed.\n".PHP_EOL;
// The current version is already installed.
if(isset($version) && ($version != false) && ($version == AIRTIME_VERSION) && !isset($opts->r)) {
echo "Airtime $version is already installed.".PHP_EOL;
echo $opts->getUsageMessage();
exit();
}
//a previous version exists.
if(isset($version) && $version != false && $version < AIRTIME_VERSION) {
// A previous version exists - if so, upgrade.
if(isset($version) && ($version != false) && ($version < AIRTIME_VERSION)) {
echo "Airtime version $version found.".PHP_EOL;
$command = "php airtime-upgrade.php";
system($command);
require_once("airtime-upgrade.php");
exit();
}
// -------------------------------------------------------------------------
// The only way we get here is if we are doing a new install or a reinstall.
// -------------------------------------------------------------------------
if(is_null($version)) {
$newInstall = true;
}
$db_install = true;
if (is_null($opts->r) && isset($opts->n) && !$newInstall){
if (is_null($opts->r) && isset($opts->n)){
$db_install = false;
}
@ -130,5 +136,9 @@ system("python ".__DIR__."/../python_apps/show-recorder/install/recorder-install
//echo PHP_EOL."*** Media Monitor Installation ***".PHP_EOL;
//system("python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-install.py");
echo PHP_EOL."*** Verifying Correct System Environment ***".PHP_EOL;
$command = "airtime-check-system";
system($command);
echo "******************************* Install Complete *******************************".PHP_EOL;

View File

@ -34,7 +34,7 @@ class AirtimeInstall
}
}
public static function CheckForVersionBeforeInstall()
public static function GetVersionInstalled()
{
global $CC_DBC, $CC_CONFIG;
@ -300,6 +300,10 @@ class AirtimeInstall
echo "* Installing airtime-update-db-settings".PHP_EOL;
$dir = AirtimeInstall::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 = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-check-system";
exec("ln -s $dir /usr/bin/airtime-check-system");
}
public static function RemoveSymlinks()
@ -307,6 +311,7 @@ class AirtimeInstall
exec("rm -f /usr/bin/airtime-import");
exec("rm -f /usr/bin/airtime-clean-storage");
exec("rm -f /usr/bin/airtime-update-db-settings");
exec("rm -f /usr/bin/airtime-check-system");
}
public static function InstallPhpCode()

View File

@ -164,10 +164,14 @@ function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n=count($lines);
for ($i=0; $i<$n; $i++) {
if (strlen($lines[$i]) > strlen($p_property))
if ($p_property == substr($lines[$i], 0, strlen($p_property))){
$lines[$i] = "$p_property = $p_value\n";
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;
}
}
}
@ -232,7 +236,8 @@ function InstallBinaries()
exec("cp -R ".$AIRTIME_UTILS." ".CONF_DIR_BINARIES);
}
$suffix = date("Ymdhis");
// 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;

View File

@ -164,10 +164,14 @@ function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n=count($lines);
for ($i=0; $i<$n; $i++) {
if (strlen($lines[$i]) > strlen($p_property))
if ($p_property == substr($lines[$i], 0, strlen($p_property))){
$lines[$i] = "$p_property = $p_value\n";
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;
}
}
}
@ -232,7 +236,7 @@ function InstallBinaries()
exec("cp -R ".$AIRTIME_UTILS." ".CONF_DIR_BINARIES);
}
$suffix = date("Ymdhis");
$suffix = date("Ymdhis")."-1.8.2";
foreach ($configFiles as $conf) {
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;

View File

@ -19,7 +19,7 @@ import json
import os
from urlparse import urlparse
AIRTIME_VERSION = "1.8.2"
AIRTIME_VERSION = "1.9.0-devel"
def api_client_factory(config):
if config["api_client"] == "airtime":

View File

@ -113,7 +113,10 @@ if __name__ == '__main__':
# initialize
g = Global()
while not g.selfcheck(): time.sleep(5000)
#NOTE: MUST EXIT HERE!! while not g.selfcheck(): time.sleep()
#Causes pypo to hang on system boot!!!
if not g.selfcheck():
sys.exit()
logger = logging.getLogger()

View File

@ -70,20 +70,32 @@ end
if output_icecast_vorbis then
#remove metadata from ogg source and merge tracks to fix bug
#with vlc and mplayer disconnecting at the end of every track
if output_icecast_vorbis_metadata then
out_vorbis = output.icecast(%vorbis,
host = icecast_host, port = icecast_port,
password = icecast_pass, mount = mount_point_vorbis,
fallible = true,
restart = true,
restart_delay = 5,
url = icecast_url,
description = icecast_description,
genre = icecast_genre,
s)
else
#remove metadata from ogg source and merge tracks to fix bug
#with vlc and mplayer disconnecting at the end of every track
s = add(normalize=false, [amplify(0.00001, noise()),s])
out_vorbis = output.icecast(%vorbis,
host = icecast_host, port = icecast_port,
password = icecast_pass, mount = mount_point_vorbis,
fallible = true,
restart = true,
restart_delay = 5,
url = icecast_url,
description = icecast_description,
genre = icecast_genre,
s)
end
out_vorbis = output.icecast(%vorbis,
host = icecast_host, port = icecast_port,
password = icecast_pass, mount = mount_point_vorbis,
fallible = true,
restart = true,
restart_delay = 5,
url = icecast_url,
description = icecast_description,
genre = icecast_genre,
s)
end

34
utils/airtime-check-system Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Airtime project.
# http://airtime.sourcefabric.org/
#
# Airtime is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Airtime is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Airtime; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# 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`
invokePwd=$PWD
cd $SCRIPTPATH
php -q airtime-check-system.php "$@" || exit 1

View File

@ -1,5 +1,11 @@
<?php
require_once '../airtime_mvc/library/php-amqplib/amqp.inc';
AirtimeCheck::ExitIfNotRoot();
$airtimeIni = AirtimeCheck::GetAirtimeConf();
$airtime_base_dir = $airtimeIni['general']['airtime_dir'];
require_once "$airtime_base_dir/library/php-amqplib/amqp.inc";
set_error_handler("myErrorHandler");
@ -7,7 +13,7 @@ AirtimeCheck::CheckOsTypeVersion();
AirtimeCheck::CheckConfigFilesExist();
$airtimeIni = AirtimeCheck::GetAirtimeConf();
$pypoCfg = AirtimeCheck::GetPypoCfg();
AirtimeCheck::GetDbConnection($airtimeIni);
@ -20,15 +26,53 @@ AirtimeCheck::CheckApacheVHostFiles();
AirtimeCheck::GetAirtimeServerVersion($pypoCfg);
AirtimeCheck::CheckPypoRunning();
AirtimeCheck::CheckLiquidsoapRunning();
AirtimeCheck::CheckIcecastRunning();
echo PHP_EOL;
if (AirtimeCheck::$check_system_ok){
output_msg("System setup looks OK!");
} else {
output_msg("There appears to be problems with your setup. Please visit");
output_msg("http://wiki.sourcefabric.org/x/HABQ for troubleshooting info.");
}
echo PHP_EOL;
class AirtimeCheck{
function output_status($key, $value)
{
echo sprintf("%-31s= %s", $key, $value).PHP_EOL;
}
function output_msg($msg)
{
//echo " -- ".PHP_EOL;
echo " -- $msg".PHP_EOL;
//echo " -- ".PHP_EOL;
}
class AirtimeCheck {
const CHECK_OK = "OK";
const CHECK_FAILED = "FAILED";
public static $check_system_ok = true;
/**
* Ensures that the user is running this PHP script with root
* permissions. If not running with root permissions, causes the
* script to exit.
*/
public static function ExitIfNotRoot()
{
// Need to check that we are superuser before running this.
if(exec("whoami") != "root"){
echo "Must be root user.\n";
exit(1);
}
}
public static function CheckPypoRunning(){
public static function CheckPypoRunning()
{
$command = "sudo svstat /etc/service/pypo";
exec($command, $output, $result);
@ -42,9 +86,11 @@ class AirtimeCheck{
$start = $pos + 4;
$end = strpos($value, ")", $start);
$status = substr($value, $start, $end-$start);
} else {
self::$check_system_ok = false;
}
echo "PYPO_PID=".$status.PHP_EOL;
output_status("PLAYOUT_ENGINE_PROCESS_ID", $status);
$status = AirtimeCheck::CHECK_FAILED;
$pos = strpos($value, ")");
@ -52,12 +98,23 @@ class AirtimeCheck{
$start = $pos + 2;
$end = strpos($value, " ", $start);
$status = substr($value, $start, $end-$start);
} else {
self::$check_system_ok = false;
}
echo "PYPO_RUNNING_SECONDS=".$status.PHP_EOL;
output_status("PLAYOUT_ENGINE_RUNNING_SECONDS", $status);
if (is_numeric($status) && (int)$status < 3) {
self::$check_system_ok = false;
output_msg("WARNING! It looks like the playout engine is continually restarting.");
$command = "tail -10 /var/log/airtime/pypo/main/current";
exec($command, $output, $result);
foreach ($output as $line) {
output_msg($line);
}
}
}
public static function CheckLiquidsoapRunning(){
public static function CheckLiquidsoapRunning()
{
$command = "sudo svstat /etc/service/pypo-liquidsoap";
exec($command, $output, $result);
@ -70,9 +127,11 @@ class AirtimeCheck{
$start = $pos + 4;
$end = strpos($value, ")", $start);
$status = substr($value, $start, $end-$start);
} else {
self::$check_system_ok = false;
}
echo "LIQUIDSOAP_PID=".$status.PHP_EOL;
output_status("LIQUIDSOAP_PROCESS_ID", $status);
$status = AirtimeCheck::CHECK_FAILED;
$pos = strpos($value, ")");
@ -80,13 +139,39 @@ class AirtimeCheck{
$start = $pos + 2;
$end = strpos($value, " ", $start);
$status = substr($value, $start, $end-$start);
} else {
self::$check_system_ok = false;
}
echo "LIQUIDSOAP_RUNNING_SECONDS=".$status.PHP_EOL;
output_status("LIQUIDSOAP_RUNNING_SECONDS", $status);
if (is_numeric($status) && (int)$status < 3) {
self::$check_system_ok = false;
output_msg("WARNING! It looks like liquidsoap is continually restarting.");
$command = "tail -10 /var/log/airtime/pypo-liquidsoap/main/current";
exec($command, $output, $result);
foreach ($output as $line) {
output_msg($line);
}
}
}
public static function CheckIcecastRunning()
{
$command = "ps aux | grep \"^icecast2\"";
exec($command, $output, $result);
$status = AirtimeCheck::CHECK_FAILED;
if (count($output) > 0){
$delimited = split("[ ]+", $output[0]);
$status = $delimited[1];
} else {
self::$check_system_ok = false;
}
output_status("ICECAST_PROCESS_ID", $status);
}
public static function CheckConfigFilesExist(){
public static function CheckConfigFilesExist()
{
//echo PHP_EOL."Verifying Config Files in /etc/airtime".PHP_EOL;
$confFiles = array("airtime.conf",
"liquidsoap.cfg",
@ -99,14 +184,16 @@ class AirtimeCheck{
$fullPath = "/etc/airtime/$cf";
if (!file_exists($fullPath)){
$allFound = AirtimeCheck::CHECK_FAILED;
self::$check_system_ok = false;
}
}
echo "AIRTIME_CONFIG_FILES=$allFound".PHP_EOL;
output_status("AIRTIME_CONFIG_FILES", $allFound);
}
public static function GetAirtimeConf(){
public static function GetAirtimeConf()
{
$ini = parse_ini_file("/etc/airtime/airtime.conf", true);
if ($ini === false){
@ -117,7 +204,8 @@ class AirtimeCheck{
return $ini;
}
public static function GetPypoCfg(){
public static function GetPypoCfg()
{
$ini = parse_ini_file("/etc/airtime/pypo.cfg", false);
if ($ini === false){
@ -128,7 +216,8 @@ class AirtimeCheck{
return $ini;
}
public static function GetDbConnection($airtimeIni){
public static function GetDbConnection($airtimeIni)
{
$host = $airtimeIni["database"]["host"];
$dbname = $airtimeIni["database"]["dbname"];
$dbuser = $airtimeIni["database"]["dbuser"];
@ -138,14 +227,16 @@ class AirtimeCheck{
if ($dbconn === false){
$status = AirtimeCheck::CHECK_FAILED;
self::$check_system_ok = false;
} else {
$status = AirtimeCheck::CHECK_OK;
}
echo "TEST_PGSQL_DATABASE=$status".PHP_EOL;
output_status("POSTGRESQL_DATABASE", $status);
}
public static function PythonLibrariesInstalled(){
public static function PythonLibrariesInstalled()
{
$command = "pip freeze | grep kombu";
exec($command, $output, $result);
@ -153,9 +244,11 @@ class AirtimeCheck{
if (count($output[0]) > 0){
$key_value = split("==", $output[0]);
$status = trim($key_value[1]);
} else {
self::$check_system_ok = false;
}
echo "PYTHON_KOMBU_VERSION=$status".PHP_EOL;
output_status("PYTHON_KOMBU_VERSION", $status);
unset($output);
$command = "pip freeze | grep poster";
@ -165,12 +258,15 @@ class AirtimeCheck{
if (count($output[0]) > 0){
$key_value = split("==", $output[0]);
$status = trim($key_value[1]);
} else {
self::$check_system_ok = false;
}
echo "PYTHON_POSTER_VERSION=$status".PHP_EOL;
output_status("PYTHON_POSTER_VERSION", $status);
}
public static function CheckDbTables(){
public static function CheckDbTables()
{
}
@ -201,7 +297,8 @@ class AirtimeCheck{
}
* */
public static function CheckRabbitMqConnection($airtimeIni){
public static function CheckRabbitMqConnection($airtimeIni)
{
try {
$status = AirtimeCheck::CHECK_OK;
$conn = new AMQPConnection($airtimeIni["rabbitmq"]["host"],
@ -210,34 +307,40 @@ class AirtimeCheck{
$airtimeIni["rabbitmq"]["password"]);
} catch (Exception $e){
$status = AirtimeCheck::CHECK_FAILED;
self::$check_system_ok = false;
}
echo "TEST_RABBITMQ_SERVER=$status".PHP_EOL;
output_status("RABBITMQ_SERVER", $status);
}
public static function GetAirtimeServerVersion($pypoCfg){
public static function GetAirtimeServerVersion($pypoCfg)
{
$baseUrl = $pypoCfg["base_url"];
$basePort = $pypoCfg["base_port"];
$apiKey = "%%api_key%%";
$url = "http://$baseUrl:$basePort/api/version/api_key/$apiKey";
echo "AIRTIME_VERSION_URL=$url".PHP_EOL;
output_status("AIRTIME_VERSION_URL", $url);
$apiKey = $pypoCfg["api_key"];
$url = "http://$baseUrl:$basePort/api/version/api_key/$apiKey";
$rh = fopen($url, "r");
if ($rh !== false){
$version = "Could not contact server";
if ($rh !== false) {
output_status("APACHE_CONFIGURED", "YES");
while (($buffer = fgets($rh)) !== false) {
$json = json_decode(trim($buffer), true);
if (!is_null($json)){
$version = $json["version"];
echo "AIRTIME_VERSION_STRING=$version".PHP_EOL;
}
}
} else {
output_status("APACHE_CONFIGURED", "NO");
}
output_status("AIRTIME_VERSION", $version);
}
public static function CheckApacheVHostFiles(){
@ -249,6 +352,7 @@ class AirtimeCheck{
foreach ($fileNames as $fn){
if (!file_exists($fn)){
$status = AirtimeCheck::CHECK_FAILED;
self::$check_system_ok = false;
}
}
@ -290,7 +394,7 @@ class AirtimeCheck{
$os_string = "Unknown";
}
echo "OS_TYPE=$os_string".PHP_EOL;
output_status("OS", $os_string);
}
}
@ -298,6 +402,9 @@ class AirtimeCheck{
// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
return true;
/*
if ($errno == E_WARNING){
if (strpos($errstr, "401") !== false){
echo "\t\tServer is running but could not find Airtime".PHP_EOL;
@ -308,6 +415,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline)
}
}
/* Don't execute PHP internal error handler */
//Don't execute PHP internal error handler
return true;
*/
}

View File

@ -112,6 +112,7 @@ function import_audio_file($p_filepath, $p_importMode = null, $p_testOnly = fals
global $STORAGE_SERVER_PATH;
global $g_fileCount;
global $g_duplicates;
global $g_replaced;
// Check parameters
$p_importMode = strtolower($p_importMode);
@ -204,9 +205,32 @@ function import_audio_file($p_filepath, $p_importMode = null, $p_testOnly = fals
// Look up md5sum in database
$duplicate = StoredFile::RecallByMd5($md5sum);
if ($duplicate) {
echo "DUPLICATE: $p_filepath\n";
$g_duplicates++;
if (PEAR::isError($duplicate)) {
echo $duplicate->getMessage();
echo "\n";
}
//row exists in database
if (isset($duplicate)) {
if (file_exists($duplicate->getRealFilePath())) {
echo "DUPLICATE: $p_filepath\n";
$g_duplicates++;
}
else{
if ($p_importMode == "copy") {
$doCopyFiles = true;
}
else if ($p_importMode == "link") {
$doCopyFiles = false;
}
$res = $duplicate->replaceFile($p_filepath, $doCopyFiles);
if (PEAR::isError($res)) {
echo $res->getMessage();
echo "\n";
return;
}
$g_replaced++;
}
return;
}
@ -323,7 +347,10 @@ if ( ($importMode == "copy") && !is_writable($CC_CONFIG["storageDir"])) {
global $g_fileCount;
global $g_duplicates;
global $g_replaced;
$g_fileCount = 0;
$g_duplicates = 0;
$g_replaced = 0;
if (is_array($files)) {
foreach ($files as $filepath) {
// absolute path
@ -356,6 +383,7 @@ if ($importMode == "copy") {
echo " *** Destination folder: ".$CC_CONFIG['storageDir']."\n";
}
echo " *** Files imported: $g_fileCount\n";
echo " *** Files restored: $g_replaced\n";
echo " *** Duplicate files (not imported): $g_duplicates\n";
if ($g_errors > 0) {
echo " *** Errors: $g_errors\n";