Merge branch '2.3.x' of dev.sourcefabric.org:airtime into 2.3.x

This commit is contained in:
Naomi 2013-02-15 16:32:43 -05:00
commit f2773fcb01
72 changed files with 8418 additions and 13592 deletions

View file

@ -1,6 +1,6 @@
<?php
// This file generated by Propel 1.5.2 convert-conf target
// from XML runtime conf file /home/rudi/reps/Airtime/airtime_mvc/build/runtime-conf.xml
// from XML runtime conf file /home/denise/airtime/airtime_mvc/build/runtime-conf.xml
$conf = array (
'datasources' =>
array (

View file

@ -262,7 +262,14 @@ class ApiController extends Zend_Controller_Action
"currentShow"=>Application_Model_Show::getCurrentShow($utcTimeNow),
"nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd)
);
// XSS exploit prevention
foreach ($result["currentShow"] as &$current) {
$current["name"] = htmlspecialchars($current["name"]);
}
foreach ($result["nextShow"] as &$next) {
$next["name"] = htmlspecialchars($next["name"]);
}
Application_Model_Show::convertToLocalTimeZone($result["currentShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::convertToLocalTimeZone($result["nextShow"],
@ -270,6 +277,17 @@ class ApiController extends Zend_Controller_Action
} else {
$result = Application_Model_Schedule::GetPlayOrderRange();
// XSS exploit prevention
$result["previous"]["name"] = htmlspecialchars($result["previous"]["name"]);
$result["current"]["name"] = htmlspecialchars($result["current"]["name"]);
$result["next"]["name"] = htmlspecialchars($result["next"]["name"]);
foreach ($result["currentShow"] as &$current) {
$current["name"] = htmlspecialchars($current["name"]);
}
foreach ($result["nextShow"] as &$next) {
$next["name"] = htmlspecialchars($next["name"]);
}
//Convert from UTC to localtime for Web Browser.
Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"],
array("starts", "ends", "start_timestamp", "end_timestamp"));
@ -316,7 +334,15 @@ class ApiController extends Zend_Controller_Action
$result[$dow[$i]] = $shows;
}
// XSS exploit prevention
foreach ($dow as $d) {
foreach ($result[$d] as &$show) {
$show["name"] = htmlspecialchars($show["name"]);
$show["url"] = htmlspecialchars($show["url"]);
}
}
//used by caller to determine if the airtime they are running or widgets in use is out of date.
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;
header("Content-type: text/javascript");

View file

@ -62,8 +62,8 @@ class AudiopreviewController extends Zend_Controller_Action
$this->view->audioFileID = $audioFileID;
// We need to decode artist and title because it gets
// encoded twice in js
$this->view->audioFileArtist = urldecode($audioFileArtist);
$this->view->audioFileTitle = urldecode($audioFileTitle);
$this->view->audioFileArtist = htmlspecialchars(urldecode($audioFileArtist));
$this->view->audioFileTitle = htmlspecialchars(urldecode($audioFileTitle));
$this->view->type = $type;
$this->_helper->viewRenderer->setRender('audio-preview');

View file

@ -139,17 +139,13 @@ class PreferenceController extends Zend_Controller_Action
{
$CC_CONFIG = Config::getConfig();
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$baseUrl = Application_Common_OsPath::getBaseDir();
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/serverbrowse/serverbrowser.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/preferences/musicdirs.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/serverbrowse/serverbrowser.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/preferences/musicdirs.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$watched_dirs_pref = new Application_Form_WatchedDirPreferences();
$this->view->form = $watched_dirs_pref;
}
$watched_dirs_pref = new Application_Form_WatchedDirPreferences();
$this->view->form = $watched_dirs_pref;
}
public function streamSettingAction()

View file

@ -479,7 +479,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->percentFilled = $show->getPercentScheduled();
$this->view->showContent = $show->getShowListContent();
$this->view->dialog = $this->view->render('schedule/show-content-dialog.phtml');
$this->view->showTitle = $show->getName();
$this->view->showTitle = htmlspecialchars($show->getName());
unset($this->view->showContent);
}
@ -573,7 +573,10 @@ class ScheduleController extends Zend_Controller_Action
return;
}
if ($isDJ) {
// in case a user was once a dj and had been assigned to a show
// but was then changed to an admin user we need to allow
// the user to edit the show as an admin (CC-4925)
if ($isDJ && !$isAdminOrPM) {
$this->view->action = "dj-edit-show";
}

View file

@ -7,6 +7,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
{
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
$rangeValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(0, 59.9);
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_general.phtml'))
));
@ -34,9 +35,13 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
'label' => _('Default Fade (s):'),
'required' => true,
'filters' => array('StringTrim'),
'validators' => array(array($notEmptyValidator, 'regex', false,
array('/^[0-9]{1,2}(\.\d{1})?$/',
'messages' => _('enter a time in seconds 0{.0}')))),
'validators' => array(
array(
$rangeValidator,
$notEmptyValidator,
'regex', false, array('/^[0-9]{1,2}(\.\d{1})?$/', 'messages' => _('enter a time in seconds 0{.0}'))
)
),
'value' => $defaultFade,
'decorators' => array(
'ViewHelper'

View file

@ -257,6 +257,10 @@ SQL;
//format original length
$formatter = new LengthFormatter($row['orig_length']);
$row['orig_length'] = $formatter->format();
// XSS exploit prevention
$row["track_title"] = htmlspecialchars($row["track_title"]);
$row["creator"] = htmlspecialchars($row["creator"]);
}
return $rows;
@ -399,10 +403,13 @@ SQL;
$entry = $this->blockItem;
$entry["id"] = $file->getDbId();
$entry["pos"] = $pos;
$entry["cliplength"] = $file->getDbLength();
$entry["cueout"] = $file->getDbCueout();
$entry["cuein"] = $file->getDbCuein();
$cue_out = Application_Common_DateHelper::calculateLengthInSeconds($entry['cueout']);
$cue_in = Application_Common_DateHelper::calculateLengthInSeconds($entry['cuein']);
$entry["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cue_out-$cue_in);
return $entry;
} else {
throw new Exception("trying to add a file that does not exist.");
@ -1241,7 +1248,7 @@ SQL;
foreach ($out as $crit) {
$criteria = $crit->getDbCriteria();
$modifier = $crit->getDbModifier();
$value = $crit->getDbValue();
$value = htmlspecialchars($crit->getDbValue());
$extra = $crit->getDbExtra();
if ($criteria == "limit") {

View file

@ -269,6 +269,10 @@ SQL;
//format original length
$formatter = new LengthFormatter($row['orig_length']);
$row['orig_length'] = $formatter->format();
// XSS exploit prevention
$row["track_title"] = htmlspecialchars($row["track_title"]);
$row["creator"] = htmlspecialchars($row["creator"]);
}
return $rows;
@ -398,6 +402,13 @@ SQL;
if ($obj instanceof CcFiles && $obj) {
$entry["cuein"] = $obj->getDbCuein();
$entry["cueout"] = $obj->getDbCueout();
$cue_out = Application_Common_DateHelper::calculateLengthInSeconds($entry['cueout']);
$cue_in = Application_Common_DateHelper::calculateLengthInSeconds($entry['cuein']);
$entry["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cue_out-$cue_in);
} elseif ($obj instanceof CcWebstream && $obj) {
$entry["cuein"] = "00:00:00";
$entry["cueout"] = $entry["cliplength"];
}
$entry["ftype"] = $objType;
}

View file

@ -203,9 +203,12 @@ class Application_Model_Scheduler
$file = CcFilesQuery::create()->findPk($fileId);
if (isset($file) && $file->visible()) {
$data["id"] = $file->getDbId();
$data["cliplength"] = $file->getDbLength();
$data["cuein"] = "00:00:00";
$data["cueout"] = $file->getDbLength();
$data["cuein"] = $file->getDbCuein();
$data["cueout"] = $file->getDbCueout();
$cuein = Application_Common_DateHelper::calculateLengthInSeconds($data["cuein"]);
$cueout = Application_Common_DateHelper::calculateLengthInSeconds($data["cueout"]);
$data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
$defaultFade = Application_Model_Preference::GetDefaultFade();
if (isset($defaultFade)) {
//fade is in format SS.uuuuuu
@ -261,9 +264,12 @@ class Application_Model_Scheduler
$file = CcFilesQuery::create()->findPk($fileId);
if (isset($file) && $file->visible()) {
$data["id"] = $file->getDbId();
$data["cliplength"] = $file->getDbLength();
$data["cuein"] = "00:00:00";
$data["cueout"] = $file->getDbLength();
$data["cuein"] = $file->getDbCuein();
$data["cueout"] = $file->getDbCueout();
$cuein = Application_Common_DateHelper::calculateLengthInSeconds($data["cuein"]);
$cueout = Application_Common_DateHelper::calculateLengthInSeconds($data["cueout"]);
$data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
$defaultFade = Application_Model_Preference::GetDefaultFade();
if (isset($defaultFade)) {
//fade is in format SS.uuuuuu
@ -325,6 +331,8 @@ class Application_Model_Scheduler
$filler->setDbStarts($DT)
->setDbEnds($this->nowDT)
->setDbClipLength($cliplength)
->setDbCueIn('00:00:00')
->setDbCueOut('00:00:00')
->setDbPlayoutStatus(-1)
->setDbInstanceId($instance->getDbId())
->save($this->con);

View file

@ -275,9 +275,9 @@ class Application_Model_ShowBuilder
$formatter = new LengthFormatter(Application_Common_DateHelper::ConvertMSToHHMMSSmm($run_time*1000));
$row['runtime'] = $formatter->format();
$row["title"] = $p_item["file_track_title"];
$row["creator"] = $p_item["file_artist_name"];
$row["album"] = $p_item["file_album_title"];
$row["title"] = htmlspecialchars($p_item["file_track_title"]);
$row["creator"] = htmlspecialchars($p_item["file_artist_name"]);
$row["album"] = htmlspecialchars($p_item["file_album_title"]);
$row["cuein"] = $p_item["cue_in"];
$row["cueout"] = $p_item["cue_out"];

View file

@ -269,7 +269,7 @@ class Application_Model_StoredFile
$md = array();
foreach ($this->_dbMD as $dbColumn => $propelColumn) {
$method = "get$propelColumn";
$md[$dbColumn] = htmlspecialchars($this->_file->$method());
$md[$dbColumn] = $this->_file->$method();
}
return $md;
@ -300,7 +300,7 @@ class Application_Model_StoredFile
if (isset($dbmd_copy[$value])) {
$propelColumn = $dbmd_copy[$value];
$method = "get$propelColumn";
$md[$constant] = htmlspecialchars($this->_file->$method());
$md[$constant] = $this->_file->$method();
}
}
}
@ -1026,8 +1026,10 @@ SQL;
$LIQUIDSOAP_ERRORS = array('TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.');
// Ask Liquidsoap if file is playable
$command = sprintf("/usr/bin/airtime-liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))' 2>&1", $audio_file);
$ls_command = sprintf('/usr/bin/airtime-liquidsoap -v -c "output.dummy(audio_to_stereo(single(%s)))" 2>&1',
escapeshellarg($audio_file));
$command = "export PATH=/usr/local/bin:/usr/bin:/bin/usr/bin/ && $ls_command";
exec($command, $output, $rv);
$isError = count($output) > 0 && in_array($output[0], $LIQUIDSOAP_ERRORS);

View file

@ -46,8 +46,8 @@ class CcScheduleTableMap extends TableMap {
$this->addColumn('CLIP_LENGTH', 'DbClipLength', 'VARCHAR', false, null, '00:00:00');
$this->addColumn('FADE_IN', 'DbFadeIn', 'TIME', false, null, '00:00:00');
$this->addColumn('FADE_OUT', 'DbFadeOut', 'TIME', false, null, '00:00:00');
$this->addColumn('CUE_IN', 'DbCueIn', 'VARCHAR', false, null, '00:00:00');
$this->addColumn('CUE_OUT', 'DbCueOut', 'VARCHAR', false, null, '00:00:00');
$this->addColumn('CUE_IN', 'DbCueIn', 'VARCHAR', true, null, null);
$this->addColumn('CUE_OUT', 'DbCueOut', 'VARCHAR', true, null, null);
$this->addColumn('MEDIA_ITEM_PLAYED', 'DbMediaItemPlayed', 'BOOLEAN', false, null, false);
$this->addForeignKey('INSTANCE_ID', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'ID', true, null, null);
$this->addColumn('PLAYOUT_STATUS', 'DbPlayoutStatus', 'SMALLINT', true, null, 1);

View file

@ -77,14 +77,12 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
/**
* The value for the cue_in field.
* Note: this column has a database default value of: '00:00:00'
* @var string
*/
protected $cue_in;
/**
* The value for the cue_out field.
* Note: this column has a database default value of: '00:00:00'
* @var string
*/
protected $cue_out;
@ -161,8 +159,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
$this->clip_length = '00:00:00';
$this->fade_in = '00:00:00';
$this->fade_out = '00:00:00';
$this->cue_in = '00:00:00';
$this->cue_out = '00:00:00';
$this->media_item_played = false;
$this->playout_status = 1;
$this->broadcasted = 0;
@ -708,7 +704,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
$v = (string) $v;
}
if ($this->cue_in !== $v || $this->isNew()) {
if ($this->cue_in !== $v) {
$this->cue_in = $v;
$this->modifiedColumns[] = CcSchedulePeer::CUE_IN;
}
@ -728,7 +724,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
$v = (string) $v;
}
if ($this->cue_out !== $v || $this->isNew()) {
if ($this->cue_out !== $v) {
$this->cue_out = $v;
$this->modifiedColumns[] = CcSchedulePeer::CUE_OUT;
}
@ -842,14 +838,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
return false;
}
if ($this->cue_in !== '00:00:00') {
return false;
}
if ($this->cue_out !== '00:00:00') {
return false;
}
if ($this->media_item_played !== false) {
return false;
}

View file

@ -39,7 +39,7 @@
<?php if (count($watched_dirs) > 0): ?>
<?php foreach($watched_dirs as $watched_dir): ?>
<dd class="block-display selected-item">
<?php echo ($watched_dir->getExistsFlag())?"":"<span class='ui-icon-alert'><img src='/css/images/warning-icon.png'></span>"?><span id="folderPath" style="display:block; width:350px"><?php echo $watched_dir->getDirectory();?></span></span>
<?php echo ($watched_dir->getExistsFlag())?"":"<span class='ui-icon-alert'><img src='/css/images/warning-icon.png'></span>"?><span id="folderPath" style="display:block; width:350px"><?php echo htmlspecialchars($watched_dir->getDirectory());?></span></span>
<span title="<?php echo _("Rescan watched directory (This is useful if it is network mount and may be out of sync with Airtime)")?>" class="ui-icon ui-icon-refresh"></span>
<span title="<?php echo _("Remove watched directory")?>" class="ui-icon ui-icon-close"></span>

View file

@ -1,3 +1,9 @@
<?php
//XSS exploit prevention
foreach ($this->md as $key => &$value) {
$value = $this->escape($value);
}
?>
<?php if($this->type == "audioclip") : ?>
<table class='library-track-md'>
<tr><td><? echo _("Title:"); ?></td><td><?php echo ($this->md["MDATA_KEY_TITLE"]);?></td></tr>
@ -41,9 +47,18 @@
<span class='static'>o</span> <span><? echo _("Static Smart Block"); ?></span><br />
<span>o</span> <span><? echo _("Audio Track"); ?></span>
</div>
<?php } ?>
<?php if ($this->type == "playlist" || ($this->type == "block" && $this->blType == "Static")) {?>
<?php
//XSS exploit prevention
/*foreach ($this->contents as &$item) {
foreach ($item as $key => &$value) {
$value = $this->escape($value);
}
}*/
?>
<?php if ($this->type == "playlist") { ?>
<div class='file-md-qtip-left'><span><? echo _("Playlist Contents: "); ?></span></div>
<?php } else { ?>
@ -88,9 +103,13 @@
<?php } elseif ($this->blType == "Dynamic") { ?>
<div class='file-md-qtip-left'><span><? echo _("Dynamic Smart Block Criteria: "); ?></span></div>
<table class='library-get-file-md table-small'>
<?php foreach ($this->contents["crit"] as $criterias) : ?>
<?php foreach ($criterias as $crit ) : ?>
<?php foreach ($this->contents["crit"] as &$criterias) : ?>
<?php foreach ($criterias as &$crit ) : ?>
<?php
// XSS exploit prevention
//$crit["value"] = htmlspecialchars($crit["value"]);
//$crit["extra"] = htmlspecialchars($crit["extra"]);
$valMaxStrLen = 25;
if (strlen($crit["value"]) > $valMaxStrLen) {
$crit["value"] = substr($crit["value"], 0, 24)."...";

View file

@ -39,7 +39,7 @@ if (isset($this->obj)) {
<a id="playlist_name_display" contenteditable="true">
<?php
if (isset($this->unsavedName)) echo $this->unsavedName;
else echo $this->obj->getName();
else echo $this->escape($this->obj->getName());
?>
</a>
</h3>

View file

@ -13,9 +13,9 @@
<?php foreach($this->showContent as $row): ?>
<tr id="au_<?php echo $row["item_id"] ?>" class="<?php if($i&1){echo "even";}else{echo "odd";}?>">
<td><?php echo $row["starts"] ?></td>
<td><?php echo $row["track_title"] ?></td>
<td><?php echo $row["creator"] ?></td>
<td><?php echo $row["album"] ?></td>
<td><?php echo $this->escape($row["track_title"]) ?></td>
<td><?php echo $this->escape($row["creator"]) ?></td>
<td><?php echo $this->escape($row["album"]) ?></td>
<td class="library_length"><?php echo $row["length"] ?></td>
<td><?php echo $row["genre"] ?></td>
</tr>

View file

@ -29,7 +29,7 @@
<div class="playlist_title">
<div id="name-error" class="errors" style="display:none;"></div>
<h3 id="ws_name">
<a id="playlist_name_display" contenteditable="true"><?php echo $this->obj->getName(); ?></a>
<a id="playlist_name_display" contenteditable="true"><?php echo $this->escape($this->obj->getName()); ?></a>
</h3>
<h4 id="ws_length"><?php echo $this->obj->getDefaultLength(); ?></h4>
</div>