Merge branch 'saas-dev-publishing' of github.com:sourcefabric/airtime into saas-dev-publishing
This commit is contained in:
commit
0efaf836b0
16 changed files with 191 additions and 26 deletions
|
@ -126,7 +126,8 @@ class Billing
|
|||
}
|
||||
else
|
||||
{
|
||||
if ($product["status"] === "Active") {
|
||||
if ($product["status"] === "Active" ||
|
||||
$product["status"] === "Suspended") {
|
||||
$airtimeProduct = $product;
|
||||
$subdomain = '';
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ define('DEFAULT_MICROTIME_FORMAT', 'Y-m-d H:i:s.u');
|
|||
define('DEFAULT_ICECAST_PORT', 8000);
|
||||
define('DEFAULT_ICECAST_PASS', 'hackme');
|
||||
define('DEFAULT_SHOW_COLOR', '76aca5');
|
||||
define('DEFAULT_INTERVAL_FORMAT', 'H:i:s.u');
|
||||
|
||||
// Metadata Keys for files
|
||||
define('MDATA_KEY_FILEPATH' , 'filepath');
|
||||
|
|
|
@ -73,6 +73,7 @@ class ApiController extends Zend_Controller_Action
|
|||
->addActionContext('update-cue-values-by-silan' , 'json')
|
||||
->addActionContext('get-usability-hint' , 'json')
|
||||
->addActionContext('poll-celery' , 'json')
|
||||
->addActionContext('recalculate-schedule' , 'json') //RKTN-260
|
||||
->initContext();
|
||||
}
|
||||
|
||||
|
@ -1524,9 +1525,40 @@ class ApiController extends Zend_Controller_Action
|
|||
$streamData = Application_Model_StreamSetting::getEnabledStreamData();
|
||||
|
||||
foreach ($streamData as $stream) {
|
||||
$m3uFile .= "#EXTINF,".$stationName." - " . strtoupper($stream['codec']) . "\r\n";
|
||||
$m3uFile .= "#EXTINF," . $stationName . " - " . strtoupper($stream['codec']) . "\r\n";
|
||||
$m3uFile .= $stream['url'] . "\r\n\r\n";
|
||||
}
|
||||
echo $m3uFile;
|
||||
}
|
||||
|
||||
public function recalculateScheduleAction()
|
||||
{
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
Zend_Session::start();
|
||||
|
||||
$scheduler = new Application_Model_Scheduler();
|
||||
session_write_close();
|
||||
|
||||
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||
|
||||
$showInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbStarts($now, Criteria::GREATER_THAN)
|
||||
//->filterByDbModifiedInstance(false)
|
||||
->orderByDbStarts()
|
||||
->find();
|
||||
//->find($this->con);
|
||||
$total = $showInstances->count();
|
||||
$progress = 0;
|
||||
foreach ($showInstances as $instance) {
|
||||
echo(round(floatval($progress / $total)*100) . "% - " . $instance->getDbId() . "\n<br>");
|
||||
flush();
|
||||
ob_flush();
|
||||
//while(@ob_end_clean());
|
||||
$scheduler->removeGaps2($instance->getDbId());
|
||||
$progress += 1;
|
||||
}
|
||||
echo("Recalculated $total shows.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,12 @@ class BillingController extends Zend_Controller_Action {
|
|||
|
||||
public function upgradeAction()
|
||||
{
|
||||
//If you're not on a trial and you're suspended, we don't let you access the plans page and redirect you to the invoices
|
||||
//page to force you to pay your bills first.
|
||||
$isTrial = (Application_Model_Preference::GetPlanLevel() == 'trial');
|
||||
if (!$isTrial && (Application_Model_Preference::getProvisioningStatus() == PROVISIONING_STATUS_SUSPENDED)) {
|
||||
$this->_redirect('billing/invoices');
|
||||
}
|
||||
|
||||
Zend_Layout::getMvcInstance()->assign('parent_page', 'Billing');
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|||
<?php echo $this->partial('partialviews/trialBox.phtml', array("is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
|
||||
|
||||
<div id="Panel" class="sticky">
|
||||
<?php if($this->suspended) : ?>
|
||||
<?php if ($this->suspended && $this->isTrial()) : ?>
|
||||
<?php echo $this->partial('partialviews/suspendedtrial.phtml'); ?>
|
||||
<?php elseif ($this->suspended && !$this->isTrial()) : ?>
|
||||
<?php echo $this->partial('partialviews/suspended.phtml'); ?>
|
||||
<?php else : ?>
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ class Application_Model_RabbitMq
|
|||
$channel->exchange_declare($exchange, $exchangeType, false, true, $autoDeleteExchange);
|
||||
|
||||
$msg = new AMQPMessage($jsonData, array('content_type' => 'text/plain'));
|
||||
|
||||
|
||||
$channel->basic_publish($msg, $exchange);
|
||||
$channel->close();
|
||||
$conn->close();
|
||||
|
|
|
@ -385,6 +385,24 @@ class Application_Model_Scheduler
|
|||
return $dt;
|
||||
}
|
||||
|
||||
private function findTimeDifference2($p_startDT, $p_endDT) {
|
||||
$startEpoch = $p_startDT->format("U.u");
|
||||
$endEpoch = $p_endDT->format("U.u");
|
||||
|
||||
//add two float numbers to 6 subsecond precision
|
||||
//DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number.
|
||||
$newEpoch = bcsub($endEpoch, (string)$startEpoch, 6);
|
||||
|
||||
$dt = DateTime::createFromFormat("U.u", $newEpoch, new DateTimeZone("UTC"));
|
||||
|
||||
if ($dt === false) {
|
||||
//PHP 5.3.2 problem
|
||||
$dt = DateTime::createFromFormat("U", intval($newEpoch), new DateTimeZone("UTC"));
|
||||
}
|
||||
|
||||
return $dt;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param DateTime startDT in UTC
|
||||
* @param string duration
|
||||
|
@ -499,12 +517,70 @@ class Application_Model_Scheduler
|
|||
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
foreach ($schedule as $item) {
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT)
|
||||
->setDbEnds($itemEndDT);
|
||||
|
||||
$itemStartDT = $itemEndDT;
|
||||
}
|
||||
|
||||
$schedule->save($this->con);
|
||||
}
|
||||
|
||||
/** Temporary hack to copy the track cue in, out, and length from the cc_files table to fix
|
||||
* incorrect track lengths (RKTN-260)
|
||||
*/
|
||||
public function removeGaps2($showInstance, $exclude = null) {
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!"));
|
||||
}
|
||||
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
|
||||
$schedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($showInstance)
|
||||
->filterByDbId($exclude, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
foreach ($schedule as $item) {
|
||||
|
||||
//START OF TIME RECALC HACK
|
||||
|
||||
//TODO: Copy the cue in, cue out, and track length from the cc_files table
|
||||
$file = $item->getCcFiles($this->con);
|
||||
if (!$file) {
|
||||
continue;
|
||||
}
|
||||
$item->setDbCueIn($file->getDbCueIn());
|
||||
$item->setDbCueOut($file->getDbCueOut());
|
||||
|
||||
$cueOut = new DateTime($file->getDbCueOut());
|
||||
$cueIn = new DateTime($file->getDbCueIn());
|
||||
$clipLength = $this->findTimeDifference2($cueIn, $cueOut);
|
||||
|
||||
//The clip length is supposed to be cue out - cue in:
|
||||
//FIXME: How do we correctly do time arithmetic in PHP without losing the millseconds?
|
||||
$item->setDbClipLength($clipLength->format(DEFAULT_INTERVAL_FORMAT));
|
||||
$item->save($this->con);
|
||||
//Ensure we don't get cached results
|
||||
CcSchedulePeer::clearInstancePool();
|
||||
//END OF TIME RECALC HACK
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
$item->setDbStarts($itemStartDT)
|
||||
->setDbEnds($itemEndDT)
|
||||
->save($this->con);
|
||||
$itemStartDT = $this->findTimeDifference($itemEndDT, $this->crossfadeDuration);
|
||||
}
|
||||
|
||||
$instance->updateDbTimeFilled($this->con); //FIXME: TIME RECALC HACK (Albert)
|
||||
|
||||
$schedule->save($this->con);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -136,9 +136,8 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
->appendBody("ERROR: Disk Quota reached.");
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$this->unknownErrorResponse();
|
||||
Logging::error($e->getMessage());
|
||||
throw $e;
|
||||
$this->serviceUnavailableResponse();
|
||||
Logging::error($e->getMessage() . "\n" . $e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,5 +248,12 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
$resp->setHttpResponseCode(400);
|
||||
$resp->appendBody("An unknown error occurred.");
|
||||
}
|
||||
|
||||
private function serviceUnavailableResponse()
|
||||
{
|
||||
$resp = $this->getResponse();
|
||||
$resp->setHttpResponseCode(400);
|
||||
$resp->appendBody("An error occurred while processing your upload. Please try again in a few minutes.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -265,10 +265,12 @@ echo($currentProduct["name"]);
|
|||
//echo Application_Model_Preference::GetPlanLevel();
|
||||
?>
|
||||
</p>
|
||||
<!--
|
||||
<div class="educational-discount">
|
||||
<h4>Are you a student or educator?</h4>
|
||||
<p>Sign up on an annual plan before the end of October to receive a special educational discount. <a href="https://www.airtime.pro/educational-discount">Find out more</a>.</p>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<h3><?php echo(_pro('Choose a plan: ')); ?></h3>
|
||||
<form id="<?php echo $form->getId(); ?>" method="<?php echo $form->getMethod() ?>" action="<?php echo
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<div class="suspension_notice">
|
||||
<H2>Station Suspended</H2>
|
||||
<p>
|
||||
<?php echo(_pro(sprintf('Your free trial is now over. To restore your station, <a href="%s">please upgrade your plan now</a>.', '/billing/upgrade'))); ?>
|
||||
</p>
|
||||
<p>
|
||||
<?php echo(_pro(sprintf('Your station will be <b>removed</b> within 7 days if you do not upgrade. If you believe this suspension was in error, <a href="%s">please contact support</a>.', 'https://sourcefabricberlin.zendesk.com/anonymous_requests/new'))); ?>
|
||||
</p>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue