Merge branch 'saas' into cc-5709-airtime-analyzer-cloud-storage-saas

Conflicts:
	airtime_mvc/application/models/StoredFile.php
	python_apps/airtime_analyzer/airtime_analyzer/analyzer_pipeline.py
This commit is contained in:
drigato 2014-11-26 11:54:07 -05:00
commit 477ac337e5
23 changed files with 70 additions and 96 deletions

View file

@ -11,17 +11,19 @@ class CORSHelper
$response = $response->setHeader('Access-Control-Allow-Origin', '*'); $response = $response->setHeader('Access-Control-Allow-Origin', '*');
$origin = $request->getHeader('Origin'); $origin = $request->getHeader('Origin');
if ((!(preg_match("/https?:\/\/localhost/", $origin) === 1)) && ($origin != "") && if ((!(preg_match("/https?:\/\/localhost/", $origin) === 1)) && ($origin != "") &&
(!in_array($origin, (!in_array($origin, self::getAllowedOrigins())))
array("http://www.airtime.pro",
"https://www.airtime.pro",
"https://account.sourcefabric.com",
"http://" . $_SERVER['SERVER_NAME'],
"https://" . $_SERVER['SERVER_NAME']
))
))
{ {
//Don't allow CORS from other domains to prevent XSS. //Don't allow CORS from other domains to prevent XSS.
throw new Zend_Controller_Action_Exception('Forbidden', 403); throw new Zend_Controller_Action_Exception('Forbidden', 403);
} }
} }
public static function getAllowedOrigins()
{
return array("http://www.airtime.pro",
"https://www.airtime.pro",
"https://account.sourcefabric.com",
"http://" . $_SERVER['SERVER_NAME'],
"https://" . $_SERVER['SERVER_NAME']);
}
} }

View file

@ -1212,9 +1212,10 @@ class ApiController extends Zend_Controller_Action
} elseif ($djtype == "dj") { } elseif ($djtype == "dj") {
//check against show dj auth //check against show dj auth
$showInfo = Application_Model_Show::getCurrentShow(); $showInfo = Application_Model_Show::getCurrentShow();
// there is current playing show // there is current playing show
if (isset($showInfo['id'])) { if (isset($showInfo[0]['id'])) {
$current_show_id = $showInfo['id']; $current_show_id = $showInfo[0]['id'];
$CcShow = CcShowQuery::create()->findPK($current_show_id); $CcShow = CcShowQuery::create()->findPK($current_show_id);
// get custom pass info from the show // get custom pass info from the show

View file

@ -1,5 +1,7 @@
<?php <?php
include('../library/phing/util/StringHelper.php');
class Application_Form_Login extends Zend_Form class Application_Form_Login extends Zend_Form
{ {
@ -10,9 +12,25 @@ class Application_Form_Login extends Zend_Form
// Set the method for the display form to POST // Set the method for the display form to POST
$this->setMethod('post'); $this->setMethod('post');
$this->addElement('hash', 'csrf', array( //If the request comes from an origin we consider safe, we disable the CSRF
'salt' => 'unique' //token checking ONLY for the login page. We do this to allow logins from WHMCS to work.
)); $request = Zend_Controller_Front::getInstance()->getRequest();
if ($request) {
$refererUrl = $request->getHeader('referer');
$originIsSafe = false;
foreach (CORSHelper::getAllowedOrigins() as $safeOrigin) {
if (StringHelper::startsWith($safeOrigin, $refererUrl)) {
$originIsSafe = true;
break;
}
}
}
if (!$originIsSafe) {
$this->addElement('hash', 'csrf', array(
'salt' => 'unique'
));
}
$this->setDecorators(array( $this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/login.phtml')) array('ViewScript', array('viewScript' => 'form/login.phtml'))

View file

@ -1112,35 +1112,36 @@ class Application_Model_Scheduler
$removedItems = CcScheduleQuery::create()->findPks($scheduledIds); $removedItems = CcScheduleQuery::create()->findPks($scheduledIds);
//check to make sure all items selected are up to date // This array is used to keep track of every show instance that was
foreach ($removedItems as $removedItem) { // effected by the track deletion. It will be used later on to
// remove gaps in the schedule and adjust crossfade times.
$effectedInstanceIds = array();
foreach ($removedItems as $removedItem) {
$instance = $removedItem->getCcShowInstances($this->con); $instance = $removedItem->getCcShowInstances($this->con);
$effectedInstanceIds[] = $instance->getDbId();
//check if instance is linked and if so get the schedule items //check if instance is linked and if so get the schedule items
//for all linked instances so we can delete them too //for all linked instances so we can delete them too
if (!$cancelShow && $instance->getCcShow()->isLinked()) { if (!$cancelShow && $instance->getCcShow()->isLinked()) {
//returns all linked instances if linked //returns all linked instances if linked
$ccShowInstances = $this->getInstances($instance->getDbId()); $ccShowInstances = $this->getInstances($instance->getDbId());
$instanceIds = array(); $instanceIds = array();
foreach ($ccShowInstances as $ccShowInstance) { foreach ($ccShowInstances as $ccShowInstance) {
$instanceIds[] = $ccShowInstance->getDbId(); $instanceIds[] = $ccShowInstance->getDbId();
} }
/* $effectedInstanceIds = array_merge($effectedInstanceIds, $instanceIds);
* Find all the schedule items that are in the same position
* as the selected item by the user. // Delete the same track, represented by $removedItem, in
* The position of each track is the same across each linked instance // each linked show instance.
*/
$itemsToDelete = CcScheduleQuery::create() $itemsToDelete = CcScheduleQuery::create()
->filterByDbPosition($removedItem->getDbPosition()) ->filterByDbPosition($removedItem->getDbPosition())
->filterByDbInstanceId($instanceIds, Criteria::IN) ->filterByDbInstanceId($instanceIds, Criteria::IN)
->find(); ->filterByDbId($removedItem->getDbId(), Criteria::NOT_EQUAL)
foreach ($itemsToDelete as $item) { ->delete($this->con);
if (!$removedItems->contains($item)) {
$removedItems->append($item);
}
}
} }
//check to truncate the currently playing item instead of deleting it. //check to truncate the currently playing item instead of deleting it.
if ($removedItem->isCurrentItem($this->epochNow)) { if ($removedItem->isCurrentItem($this->epochNow)) {
@ -1165,29 +1166,11 @@ class Application_Model_Scheduler
} else { } else {
$removedItem->delete($this->con); $removedItem->delete($this->con);
} }
// update is_scheduled in cc_files but only if
// the file is not scheduled somewhere else
$fileId = $removedItem->getDbFileId();
// check if the removed item is scheduled somewhere else
$futureScheduledFiles = Application_Model_Schedule::getAllFutureScheduledFiles();
if (!is_null($fileId) && !in_array($fileId, $futureScheduledFiles)) {
$db_file = CcFilesQuery::create()->findPk($fileId, $this->con);
$db_file->setDbIsScheduled(false)->save($this->con);
}
} }
Application_Model_StoredFile::updatePastFilesIsScheduled();
if ($adjustSched === true) { if ($adjustSched === true) {
//get the show instances of the shows we must adjust times for. foreach ($effectedInstanceIds as $instance) {
foreach ($removedItems as $item) {
$instance = $item->getDBInstanceId();
if (!in_array($instance, $showInstances)) {
$showInstances[] = $instance;
}
}
foreach ($showInstances as $instance) {
$this->removeGaps($instance); $this->removeGaps($instance);
$this->calculateCrossfades($instance); $this->calculateCrossfades($instance);
} }
@ -1195,7 +1178,7 @@ class Application_Model_Scheduler
//update the status flag in cc_schedule. //update the status flag in cc_schedule.
$instances = CcShowInstancesQuery::create() $instances = CcShowInstancesQuery::create()
->filterByPrimaryKeys($showInstances) ->filterByPrimaryKeys($effectedInstanceIds)
->find($this->con); ->find($this->con);
foreach ($instances as $instance) { foreach ($instances as $instance) {

View file

@ -1311,7 +1311,6 @@ SQL;
$results['nextShow'][0] = array( $results['nextShow'][0] = array(
"id" => $rows[$i]['id'], "id" => $rows[$i]['id'],
"instance_id" => $rows[$i]['instance_id'], "instance_id" => $rows[$i]['instance_id'],
"instance_description" => $rows[$i]['instance_description'],
"name" => $rows[$i]['name'], "name" => $rows[$i]['name'],
"description" => $rows[$i]['description'], "description" => $rows[$i]['description'],
"url" => $rows[$i]['url'], "url" => $rows[$i]['url'],

View file

@ -362,7 +362,8 @@ SQL;
{ {
$exists = false; $exists = false;
try { try {
$exists = file_exists($this->getFilePath()); $filePath = $this->getFilePath();
$exists = (file_exists($this->getFilePath()) && !is_dir($filePath));
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
} }

View file

@ -80,35 +80,6 @@ class Rest_MediaController extends Zend_Rest_Controller
$this->fileNotFoundResponse(); $this->fileNotFoundResponse();
} }
} }
public function clearAction()
{
if (!$this->verifyAuth(true, true))
{
return;
}
//set file_exists flag to false for every file
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
$selectCriteria = new Criteria();
$selectCriteria->add(CcFilesPeer::FILE_EXISTS, true);
$updateCriteria = new Criteria();
$updateCriteria->add(CcFilesPeer::FILE_EXISTS, false);
BasePeer::doUpdate($selectCriteria, $updateCriteria, $con);
//delete all files and directories under .../imported
$path = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."/srv/airtime/stor/imported/*" : "/srv/airtime/stor/imported/*";
exec("rm -rf $path");
//update disk_usage value in cc_pref
$storDir = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."srv/airtime/stor" : "/srv/airtime/stor";
$diskUsage = shell_exec("du -sb $storDir | awk '{print $1}'");
Application_Model_Preference::setDiskUsage($diskUsage);
$this->getResponse()
->setHttpResponseCode(200)
->appendBody("Library has been cleared");
}
public function getAction() public function getAction()
{ {
@ -267,8 +238,7 @@ class Rest_MediaController extends Zend_Rest_Controller
{ {
return; return;
} }
$id = $this->getId(); $id = $this->getId();
if (!$id) { if (!$id) {
return; return;

View file

@ -27,7 +27,7 @@ QUEUE = "airtime-uploads"
Airtime's music library directory. Lastly, the extracted metadata is Airtime's music library directory. Lastly, the extracted metadata is
reported back to the Airtime web application. reported back to the Airtime web application.
There's a couple of Very Important technical details and contraints that you There's a couple of Very Important technical details and constraints that you
need to know if you're going to work on this code: need to know if you're going to work on this code:
1) airtime_analyzer is designed so it doesn't have to run on the same 1) airtime_analyzer is designed so it doesn't have to run on the same

View file

@ -18,7 +18,7 @@ post_file() {
airtime_conf_path=/etc/airtime/airtime.conf airtime_conf_path=/etc/airtime/airtime.conf
#maps the instance_path to the url #maps the instance_path to the url
vhost_file=/mnt/airtimepro/system/vhost.map vhost_file=/etc/apache2/airtime/vhost.map
#instance_path will look like 1/1384, for example #instance_path will look like 1/1384, for example
instance_path=$(echo ${file_path} | grep -Po "(?<=($base_instance_path)).*?(?=/srv)") instance_path=$(echo ${file_path} | grep -Po "(?<=($base_instance_path)).*?(?=/srv)")

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Account Plans</title> <title>Account Plans</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Add Media Skeleton Present</title> <title>Add Media Skeleton Present</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Billing Account Details</title> <title>Billing Account Details</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Billing Menu Contents</title> <title>Billing Menu Contents</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Calendar Add Show Skeleton</title> <title>Calendar Add Show Skeleton</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Calendar Day Week Month Views</title> <title>Calendar Day Week Month Views</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Calendar Skeleton Present</title> <title>Calendar Skeleton Present</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Invoices Skeleton</title> <title>Invoices Skeleton</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Library Skeleton Present</title> <title>Library Skeleton Present</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Listen Button Skeleton</title> <title>Listen Button Skeleton</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Login and Logout</title> <title>Login and Logout</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Login</title> <title>Login</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>Preferences Skeletons</title> <title>Preferences Skeletons</title>
</head> </head>
<body> <body>

View file

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> <head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://bananas.airtime.pro/" />
<title>System Menu Contents</title> <title>System Menu Contents</title>
</head> </head>
<body> <body>