From 32bdbe1ad69777dbc65b948b5be75cc4b9bb5383 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Fri, 14 Nov 2014 11:12:10 -0500 Subject: [PATCH 01/17] Improved some comments --- .../airtime_analyzer/airtime_analyzer/analyzer_pipeline.py | 2 +- .../airtime_analyzer/airtime_analyzer/message_listener.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python_apps/airtime_analyzer/airtime_analyzer/analyzer_pipeline.py b/python_apps/airtime_analyzer/airtime_analyzer/analyzer_pipeline.py index 39c558bac..e36c03688 100644 --- a/python_apps/airtime_analyzer/airtime_analyzer/analyzer_pipeline.py +++ b/python_apps/airtime_analyzer/airtime_analyzer/analyzer_pipeline.py @@ -52,7 +52,7 @@ class AnalyzerPipeline: metadata = dict() metadata = MetadataAnalyzer.analyze(audio_file_path, metadata) metadata = FileMoverAnalyzer.move(audio_file_path, import_directory, original_filename, metadata) - metadata["import_status"] = 0 # imported + metadata["import_status"] = 0 # Successfully imported # Note that the queue we're putting the results into is our interprocess communication # back to the main process. diff --git a/python_apps/airtime_analyzer/airtime_analyzer/message_listener.py b/python_apps/airtime_analyzer/airtime_analyzer/message_listener.py index 9b890321c..495682d7b 100644 --- a/python_apps/airtime_analyzer/airtime_analyzer/message_listener.py +++ b/python_apps/airtime_analyzer/airtime_analyzer/message_listener.py @@ -26,7 +26,7 @@ QUEUE = "airtime-uploads" Airtime's music library directory. Lastly, the extracted metadata is 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: 1) airtime_analyzer is designed so it doesn't have to run on the same From 2cfe08b33a7618dee3347e3213be3114108cc42c Mon Sep 17 00:00:00 2001 From: drigato Date: Tue, 18 Nov 2014 14:58:27 -0500 Subject: [PATCH 02/17] Updated FTP upload hook script with new vhost.map file location --- python_apps/airtime_analyzer/tools/ftp-upload-hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh b/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh index 216716625..f0a00fbe9 100755 --- a/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh +++ b/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh @@ -18,7 +18,7 @@ post_file() { airtime_conf_path=/etc/airtime/airtime.conf #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=$(echo ${file_path} | grep -Po "(?<=($base_instance_path)).*?(?=/srv)") From e7e1926896ab102086085ee7cb19067ba08b2cb4 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Tue, 18 Nov 2014 17:11:09 -0500 Subject: [PATCH 03/17] CC-5950: Fix for issue where clear button in Recent Uploads didn't work sometimes --- airtime_mvc/application/models/StoredFile.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 0e588bbe9..8c5910182 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -355,7 +355,13 @@ SQL; { $exists = false; try { - $exists = file_exists($this->getFilePath()); + //Explicitly check filepath because if it's blank, getFilePath() can + //still return a directory that exists. + if (!$this->_file->getDbFilepath()) { + $exists = false; + } else { + $exists = file_exists($this->getFilePath()); + } } catch (Exception $e) { return false; } From 6460854fdad351a91fe054a321caa7ab54b3a040 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 10 Nov 2014 16:07:23 -0500 Subject: [PATCH 04/17] Fixed 'clear' button not working when files failed to import --- .../modules/rest/controllers/MediaController.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 87af946bb..243eeeb50 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -1,8 +1,13 @@ findPk($id); + // Since we check for this value when deleting files, set it first + $file->setDbDirectory(self::MUSIC_DIRS_STOR_PK); $requestData = json_decode($this->getRequest()->getRawBody(), true); $whiteList = $this->removeBlacklistedFieldsFromRequestData($requestData); @@ -228,7 +235,7 @@ class Rest_MediaController extends Zend_Rest_Controller $fileSizeBytes = filesize($requestData["full_path"]); if (!isset($fileSizeBytes) || $fileSizeBytes === false) { - $file->setDbImportStatus(2)->save(); + $file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save(); $this->fileNotFoundResponse(); return; } @@ -244,7 +251,6 @@ class Rest_MediaController extends Zend_Rest_Controller $filePathRelativeToStor = substr($fullPath, strlen($storDir)); $file->setDbFilepath($filePathRelativeToStor); - $file->setDbDirectory(1); //1 corresponds to the default stor/imported directory. } } @@ -259,7 +265,7 @@ class Rest_MediaController extends Zend_Rest_Controller ->setHttpResponseCode(200) ->appendBody(json_encode(CcFiles::sanitizeResponse($file))); } else { - $file->setDbImportStatus(2)->save(); + $file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save(); $this->fileNotFoundResponse(); } } @@ -270,6 +276,7 @@ class Rest_MediaController extends Zend_Rest_Controller { return; } + $id = $this->getId(); if (!$id) { From 11a31375df4ccf0313e1f07ca8287b1424840770 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Tue, 18 Nov 2014 17:41:44 -0500 Subject: [PATCH 05/17] Slightly more robust fix for the last issue --- airtime_mvc/application/models/StoredFile.php | 17 ++++++++--------- .../rest/controllers/MediaController.php | 3 +-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 8c5910182..ab5ada697 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -355,13 +355,8 @@ SQL; { $exists = false; try { - //Explicitly check filepath because if it's blank, getFilePath() can - //still return a directory that exists. - if (!$this->_file->getDbFilepath()) { - $exists = false; - } else { - $exists = file_exists($this->getFilePath()); - } + $filePath = $this->getFilePath(); + $exists = (file_exists($this->getFilePath()) && !is_dir($filePath)); } catch (Exception $e) { return false; } @@ -504,11 +499,15 @@ SQL; $music_dir = Application_Model_MusicDir::getDirByPK($this-> _file->getDbDirectory()); if (!$music_dir) { - throw new Exception("Invalid music_dir for file in database."); + throw new Exception(_("Invalid music_dir for file in database.")); } + $directory = $music_dir->getDirectory(); $filepath = $this->_file->getDbFilepath(); - + if (!$filepath) { + throw new Exception(sprintf(_("Blank file path for file %s (id: %s) in database."), $this->_file->getDbTrackTitle(), $this->getId())); + } + return Application_Common_OsPath::join($directory, $filepath); } diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 243eeeb50..7cc5f370a 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -276,8 +276,7 @@ class Rest_MediaController extends Zend_Rest_Controller { return; } - - + $id = $this->getId(); if (!$id) { return; From dd3b54f8ed002e72726f95ac48e284b578fa104b Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Tue, 18 Nov 2014 18:15:45 -0500 Subject: [PATCH 06/17] Actually delete files from the database via the media REST API --- airtime_mvc/application/models/StoredFile.php | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index ab5ada697..e4ad0cfdd 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -370,9 +370,7 @@ SQL; * */ public function delete() - { - $filepath = $this->getFilePath(); - + { // Check if the file is scheduled to be played in the future if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) { throw new DeleteScheduledFileException(); @@ -390,17 +388,21 @@ SQL; $type = $music_dir->getType(); - if (file_exists($filepath) && $type == "stor") { - try { + Logging::info($_SERVER["HTTP_HOST"].": User ".$user->getLogin()." is deleting file: ".$this->_file->getDbTrackTitle()." - file id: ".$this->_file->getDbId()); + + try { + if ($this->existsOnDisk() && $type == "stor") { + $filepath = $this->getFilePath(); //Update the user's disk usage Application_Model_Preference::updateDiskUsage(-1 * abs(filesize($filepath))); - unlink($filepath); - } catch (Exception $e) { - Logging::error($e->getMessage()); - return; } + } catch (Exception $e) { + Logging::warning($e->getMessage()); + //If the file didn't exist on disk, that's fine, we still want to + //remove it from the database, so we continue here. } +<<<<<<< Updated upstream Logging::info("User ".$user->getLogin()." is deleting file: ".$this->_file->getDbTrackTitle()." - file id: ".$this->_file->getDbId()); // set hidden flag to true @@ -408,6 +410,9 @@ SQL; $this->_file->setDbFileExists(false); $this->_file->save(); +======= + +>>>>>>> Stashed changes // need to explicitly update any playlist's and block's length // that contains the file getting deleted $fileId = $this->_file->getDbId(); @@ -424,6 +429,9 @@ SQL; $bl->setDbLength($bl->computeDbLength(Propel::getConnection(CcBlockPeer::DATABASE_NAME))); $bl->save(); } + + //We actually do want to delete the file from the database here + $this->_file->delete(); } /** From c829b6bf95fec2e5d31c201bad8a9142e7aeb344 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Tue, 18 Nov 2014 18:17:19 -0500 Subject: [PATCH 07/17] Fix bad merge --- airtime_mvc/application/models/StoredFile.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index e4ad0cfdd..8144f9a27 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -387,7 +387,6 @@ SQL; assert($music_dir); $type = $music_dir->getType(); - Logging::info($_SERVER["HTTP_HOST"].": User ".$user->getLogin()." is deleting file: ".$this->_file->getDbTrackTitle()." - file id: ".$this->_file->getDbId()); try { @@ -402,17 +401,7 @@ SQL; //If the file didn't exist on disk, that's fine, we still want to //remove it from the database, so we continue here. } -<<<<<<< Updated upstream - Logging::info("User ".$user->getLogin()." is deleting file: ".$this->_file->getDbTrackTitle()." - file id: ".$this->_file->getDbId()); - // set hidden flag to true - //$this->_file->setDbHidden(true); - $this->_file->setDbFileExists(false); - $this->_file->save(); - -======= - ->>>>>>> Stashed changes // need to explicitly update any playlist's and block's length // that contains the file getting deleted $fileId = $this->_file->getDbId(); From 12550112fdc21f3589ba6f3844b4f4cd077a5a0f Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 19 Nov 2014 11:28:03 -0500 Subject: [PATCH 08/17] Remove base URL from selenium tests to make the Selenium IDE happy --- tests/selenium/Account Plans.html | 196 ------------------ .../selenium/Add Media Skeleton Present.html | 2 +- .../selenium/Calendar Add Show Skeleton.html | 2 +- .../Calendar Day Week Month Views.html | 2 +- tests/selenium/Calendar Skeleton Present.html | 2 +- tests/selenium/Library Skeleton Present.html | 2 +- tests/selenium/Listen Button Skeleton.html | 2 +- tests/selenium/Login and Logout.html | 2 +- tests/selenium/Login.html | 2 +- tests/selenium/Preferences Skeletons.html | 2 +- tests/selenium/System Menu Contents.html | 2 +- 11 files changed, 10 insertions(+), 206 deletions(-) delete mode 100644 tests/selenium/Account Plans.html diff --git a/tests/selenium/Account Plans.html b/tests/selenium/Account Plans.html deleted file mode 100644 index a320b9dfb..000000000 --- a/tests/selenium/Account Plans.html +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - -Account Plans - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account Plans
open/billing/upgrade
clickAndWaitlink=Account Plans
verifyElementPresentid=hobbyist_grid_price
verifyElementPresentid=starter_grid_price
verifyElementPresentid=plus_grid_price
verifyElementPresentid=premium_grid_price
verifyTextid=hobbyist_grid_price$9.95 / month
verifyTextid=starter_grid_price$39.95 / month
verifyTextid=plus_grid_price$64.95 / month
verifyTextid=premium_grid_price$99.95 / month
verifyElementPresentid=current_plan
verifyElementPresentid=newproductbillingcycle-monthly
verifyElementPresentid=newproductbillingcycle-annually
verifyElementPresentid=newproductid-25
verifyElementPresentid=newproductid-26
verifyElementPresentid=newproductid-27
verifyElementPresentid=newproductid-28
verifyElementPresentcss=span.subtotal
verifyElementPresentid=firstname
verifyElementPresentid=lastname
verifyElementPresentid=companyname
verifyElementPresentid=email
verifyElementPresentid=address1
verifyElementPresentid=address2
verifyElementPresentid=city
verifyElementPresentid=state
verifyElementPresentid=postcode
verifyElementPresentid=country
verifyElementPresentid=phonenumber
verifyElementPresentid=securityqid
verifyElementPresentid=securityqans
verifyElementPresentid=customfields-7
verifyElementPresentid=customfields-71
verifyElementPresentid=paymentmethod-paypal
verifyElementPresent//div[@id='total_box']/b[2]
verifyElementPresentcss=input[type="submit"]
- - diff --git a/tests/selenium/Add Media Skeleton Present.html b/tests/selenium/Add Media Skeleton Present.html index 597721829..d9def30cf 100644 --- a/tests/selenium/Add Media Skeleton Present.html +++ b/tests/selenium/Add Media Skeleton Present.html @@ -3,7 +3,7 @@ - + Add Media Skeleton Present diff --git a/tests/selenium/Calendar Add Show Skeleton.html b/tests/selenium/Calendar Add Show Skeleton.html index d16810637..6ab57a89e 100644 --- a/tests/selenium/Calendar Add Show Skeleton.html +++ b/tests/selenium/Calendar Add Show Skeleton.html @@ -3,7 +3,7 @@ - + Calendar Add Show Skeleton diff --git a/tests/selenium/Calendar Day Week Month Views.html b/tests/selenium/Calendar Day Week Month Views.html index 6923d1c8a..6cefa5625 100644 --- a/tests/selenium/Calendar Day Week Month Views.html +++ b/tests/selenium/Calendar Day Week Month Views.html @@ -3,7 +3,7 @@ - + Calendar Day Week Month Views diff --git a/tests/selenium/Calendar Skeleton Present.html b/tests/selenium/Calendar Skeleton Present.html index 9275f8ecb..6aeb2f102 100644 --- a/tests/selenium/Calendar Skeleton Present.html +++ b/tests/selenium/Calendar Skeleton Present.html @@ -3,7 +3,7 @@ - + Calendar Skeleton Present diff --git a/tests/selenium/Library Skeleton Present.html b/tests/selenium/Library Skeleton Present.html index 4c34a993b..a6f01315b 100644 --- a/tests/selenium/Library Skeleton Present.html +++ b/tests/selenium/Library Skeleton Present.html @@ -3,7 +3,7 @@ - + Library Skeleton Present diff --git a/tests/selenium/Listen Button Skeleton.html b/tests/selenium/Listen Button Skeleton.html index 5fb225fd6..b0f783879 100644 --- a/tests/selenium/Listen Button Skeleton.html +++ b/tests/selenium/Listen Button Skeleton.html @@ -3,7 +3,7 @@ - + Listen Button Skeleton diff --git a/tests/selenium/Login and Logout.html b/tests/selenium/Login and Logout.html index 5a72b31de..1cc6a906a 100644 --- a/tests/selenium/Login and Logout.html +++ b/tests/selenium/Login and Logout.html @@ -3,7 +3,7 @@ - + Login and Logout diff --git a/tests/selenium/Login.html b/tests/selenium/Login.html index a51883ea7..83aaf18d7 100644 --- a/tests/selenium/Login.html +++ b/tests/selenium/Login.html @@ -3,7 +3,7 @@ - + Login diff --git a/tests/selenium/Preferences Skeletons.html b/tests/selenium/Preferences Skeletons.html index 67fab75ef..47f114551 100644 --- a/tests/selenium/Preferences Skeletons.html +++ b/tests/selenium/Preferences Skeletons.html @@ -3,7 +3,7 @@ - + Preferences Skeletons diff --git a/tests/selenium/System Menu Contents.html b/tests/selenium/System Menu Contents.html index 2a2a4077c..a064cabbb 100644 --- a/tests/selenium/System Menu Contents.html +++ b/tests/selenium/System Menu Contents.html @@ -3,7 +3,7 @@ - + System Menu Contents From 9087db20432436857100520baa1965ac9169840d Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 19 Nov 2014 11:30:32 -0500 Subject: [PATCH 09/17] Removed base URL from saas Selenium tests and added missing Account Plans tests --- tests/selenium/Account Plans.html | 196 ++++++++++++++++++++ tests/selenium/Billing Account Details.html | 2 +- tests/selenium/Billing Menu Contents.html | 2 +- tests/selenium/Invoices Skeleton.html | 2 +- 4 files changed, 199 insertions(+), 3 deletions(-) create mode 100644 tests/selenium/Account Plans.html diff --git a/tests/selenium/Account Plans.html b/tests/selenium/Account Plans.html new file mode 100644 index 000000000..4c51f4a88 --- /dev/null +++ b/tests/selenium/Account Plans.html @@ -0,0 +1,196 @@ + + + + + + +Account Plans + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Account Plans
open/billing/upgrade
clickAndWaitlink=Account Plans
verifyElementPresentid=hobbyist_grid_price
verifyElementPresentid=starter_grid_price
verifyElementPresentid=plus_grid_price
verifyElementPresentid=premium_grid_price
verifyTextid=hobbyist_grid_price$9.95 / month
verifyTextid=starter_grid_price$39.95 / month
verifyTextid=plus_grid_price$64.95 / month
verifyTextid=premium_grid_price$99.95 / month
verifyElementPresentid=current_plan
verifyElementPresentid=newproductbillingcycle-monthly
verifyElementPresentid=newproductbillingcycle-annually
verifyElementPresentid=newproductid-25
verifyElementPresentid=newproductid-26
verifyElementPresentid=newproductid-27
verifyElementPresentid=newproductid-28
verifyElementPresentcss=span.subtotal
verifyElementPresentid=firstname
verifyElementPresentid=lastname
verifyElementPresentid=companyname
verifyElementPresentid=email
verifyElementPresentid=address1
verifyElementPresentid=address2
verifyElementPresentid=city
verifyElementPresentid=state
verifyElementPresentid=postcode
verifyElementPresentid=country
verifyElementPresentid=phonenumber
verifyElementPresentid=securityqid
verifyElementPresentid=securityqans
verifyElementPresentid=customfields-7
verifyElementPresentid=customfields-71
verifyElementPresentid=paymentmethod-paypal
verifyElementPresent//div[@id='total_box']/b[2]
verifyElementPresentcss=input[type="submit"]
+ + diff --git a/tests/selenium/Billing Account Details.html b/tests/selenium/Billing Account Details.html index 13d428ad4..e09acc9c8 100644 --- a/tests/selenium/Billing Account Details.html +++ b/tests/selenium/Billing Account Details.html @@ -3,7 +3,7 @@ - + Billing Account Details diff --git a/tests/selenium/Billing Menu Contents.html b/tests/selenium/Billing Menu Contents.html index 22e8db439..af5d43247 100644 --- a/tests/selenium/Billing Menu Contents.html +++ b/tests/selenium/Billing Menu Contents.html @@ -3,7 +3,7 @@ - + Billing Menu Contents diff --git a/tests/selenium/Invoices Skeleton.html b/tests/selenium/Invoices Skeleton.html index 397fb376d..bad141d2c 100644 --- a/tests/selenium/Invoices Skeleton.html +++ b/tests/selenium/Invoices Skeleton.html @@ -3,7 +3,7 @@ - + Invoices Skeleton From 5fdca78041b4234dc3b464232f7cbcdea80cdca4 Mon Sep 17 00:00:00 2001 From: drigato Date: Wed, 19 Nov 2014 14:10:53 -0500 Subject: [PATCH 10/17] Scheduler->removeItems optimization --- airtime_mvc/application/models/Scheduler.php | 50 +++++++------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 39415beaa..05b55bdba 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -1112,9 +1112,12 @@ class Application_Model_Scheduler $removedItems = CcScheduleQuery::create()->findPks($scheduledIds); - //check to make sure all items selected are up to date - foreach ($removedItems as $removedItem) { + // This array is used to keep track of every show instance that was + // 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); //check if instance is linked and if so get the schedule items @@ -1122,25 +1125,22 @@ class Application_Model_Scheduler if (!$cancelShow && $instance->getCcShow()->isLinked()) { //returns all linked instances if linked $ccShowInstances = $this->getInstances($instance->getDbId()); + $instanceIds = array(); foreach ($ccShowInstances as $ccShowInstance) { $instanceIds[] = $ccShowInstance->getDbId(); } - /* - * Find all the schedule items that are in the same position - * as the selected item by the user. - * The position of each track is the same across each linked instance - */ + $effectedInstanceIds = array_merge($effectedInstanceIds, $instanceIds); + + // Delete the same track, represented by $removedItem, in + // each linked show instance. $itemsToDelete = CcScheduleQuery::create() ->filterByDbPosition($removedItem->getDbPosition()) ->filterByDbInstanceId($instanceIds, Criteria::IN) - ->find(); - foreach ($itemsToDelete as $item) { - if (!$removedItems->contains($item)) { - $removedItems->append($item); - } - } + ->filterByDbId($removedItem->getDbId(), Criteria::NOT_EQUAL) + ->delete($this->con); } + //check to truncate the currently playing item instead of deleting it. if ($removedItem->isCurrentItem($this->epochNow)) { @@ -1165,29 +1165,11 @@ class Application_Model_Scheduler } else { $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) { - //get the show instances of the shows we must adjust times for. - foreach ($removedItems as $item) { - - $instance = $item->getDBInstanceId(); - if (!in_array($instance, $showInstances)) { - $showInstances[] = $instance; - } - } - - foreach ($showInstances as $instance) { + foreach ($effectedInstanceIds as $instance) { $this->removeGaps($instance); $this->calculateCrossfades($instance); } @@ -1195,7 +1177,7 @@ class Application_Model_Scheduler //update the status flag in cc_schedule. $instances = CcShowInstancesQuery::create() - ->filterByPrimaryKeys($showInstances) + ->filterByPrimaryKeys($effectedInstanceIds) ->find($this->con); foreach ($instances as $instance) { From 766c8270942247cd4a55856408e25c07508c02a1 Mon Sep 17 00:00:00 2001 From: drigato Date: Wed, 19 Nov 2014 16:04:06 -0500 Subject: [PATCH 11/17] Removed undefined index from show info array --- airtime_mvc/application/models/Show.php | 1 - 1 file changed, 1 deletion(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index ba9afbeb7..e75d07441 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1311,7 +1311,6 @@ SQL; $results['nextShow'][0] = array( "id" => $rows[$i]['id'], "instance_id" => $rows[$i]['instance_id'], - "instance_description" => $rows[$i]['instance_description'], "name" => $rows[$i]['name'], "description" => $rows[$i]['description'], "url" => $rows[$i]['url'], From 767562922acfffe788a9d87930f0f972aa1bfbec Mon Sep 17 00:00:00 2001 From: drigato Date: Wed, 19 Nov 2014 17:09:54 -0500 Subject: [PATCH 12/17] Schedule->removeItems optimization fix for deleting the current playing track --- airtime_mvc/application/models/Scheduler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 05b55bdba..4208ff5c7 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -1119,6 +1119,7 @@ class Application_Model_Scheduler foreach ($removedItems as $removedItem) { $instance = $removedItem->getCcShowInstances($this->con); + $effectedInstanceIds[] = $instance->getDbId(); //check if instance is linked and if so get the schedule items //for all linked instances so we can delete them too From cea3fc5302ccb9972559d13b07a7934f767a64c9 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 20 Nov 2014 13:59:59 -0500 Subject: [PATCH 13/17] Temporarily fix live stream auth (show source) --- airtime_mvc/application/controllers/ApiController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index dde86e8be..a369dfb32 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -1225,6 +1225,8 @@ class ApiController extends Zend_Controller_Action } elseif ($djtype == "dj") { //check against show dj auth $showInfo = Application_Model_Show::getCurrentShow(); + $showInfo = $showInfo[0]; //When did this change??? - Albert + // there is current playing show if (isset($showInfo['id'])) { $current_show_id = $showInfo['id']; From 29fd728d7d6089a46576ac165a4c35489e22114b Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 20 Nov 2014 14:30:42 -0500 Subject: [PATCH 14/17] Undo live stream auth action breakage --- airtime_mvc/application/controllers/ApiController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index a369dfb32..fde52a369 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -1225,11 +1225,10 @@ class ApiController extends Zend_Controller_Action } elseif ($djtype == "dj") { //check against show dj auth $showInfo = Application_Model_Show::getCurrentShow(); - $showInfo = $showInfo[0]; //When did this change??? - Albert // there is current playing show - if (isset($showInfo['id'])) { - $current_show_id = $showInfo['id']; + if (isset($showInfo[0]['id'])) { + $current_show_id = $showInfo[0]['id']; $CcShow = CcShowQuery::create()->findPK($current_show_id); // get custom pass info from the show From 8ffd70781ba07e30b19f95575f7d08c2cedcd8c6 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 20 Nov 2014 16:46:21 -0500 Subject: [PATCH 15/17] Remove clearAction from the media REST API for security --- .../application/modules/rest/controllers/MediaController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 7cc5f370a..8d8672a9f 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -78,6 +78,8 @@ class Rest_MediaController extends Zend_Rest_Controller } } +/* This action is extremely dangerous and a horrible idea without CSRF protection. + public function clearAction() { if (!$this->verifyAuth(true, true)) @@ -113,6 +115,7 @@ class Rest_MediaController extends Zend_Rest_Controller ->setHttpResponseCode(200) ->appendBody("Library has been cleared"); } +*/ public function getAction() { From 7db571d10366ad77f037845892873fe45cfd7897 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 20 Nov 2014 16:47:02 -0500 Subject: [PATCH 16/17] Remove clearAction from the media REST API for security --- .../rest/controllers/MediaController.php | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 8d8672a9f..232ac3529 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -77,45 +77,6 @@ class Rest_MediaController extends Zend_Rest_Controller $this->fileNotFoundResponse(); } } - -/* This action is extremely dangerous and a horrible idea without CSRF protection. - - 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 - $musicDir = CcMusicDirsQuery::create() - ->filterByType('stor') - ->filterByExists(true) - ->findOne(); - $storPath = $musicDir->getDirectory(); - - $freeSpace = disk_free_space($storPath); - $totalSpace = disk_total_space($storPath); - - Application_Model_Preference::setDiskUsage($totalSpace - $freeSpace); - - $this->getResponse() - ->setHttpResponseCode(200) - ->appendBody("Library has been cleared"); - } -*/ public function getAction() { From a62e98beb4709a9fa3bbeb65d7075a6257a25765 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 20 Nov 2014 19:33:11 -0500 Subject: [PATCH 17/17] Fix logins from WHMCS by disabling CSRF token on login page for trusted origins --- airtime_mvc/application/common/CORSHelper.php | 18 +++++++------- airtime_mvc/application/forms/Login.php | 24 ++++++++++++++++--- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/airtime_mvc/application/common/CORSHelper.php b/airtime_mvc/application/common/CORSHelper.php index 6febb0f1b..fac6e3fdd 100644 --- a/airtime_mvc/application/common/CORSHelper.php +++ b/airtime_mvc/application/common/CORSHelper.php @@ -11,17 +11,19 @@ class CORSHelper $response = $response->setHeader('Access-Control-Allow-Origin', '*'); $origin = $request->getHeader('Origin'); if ((!(preg_match("/https?:\/\/localhost/", $origin) === 1)) && ($origin != "") && - (!in_array($origin, - array("http://www.airtime.pro", - "https://www.airtime.pro", - "https://account.sourcefabric.com", - "http://" . $_SERVER['SERVER_NAME'], - "https://" . $_SERVER['SERVER_NAME'] - )) - )) + (!in_array($origin, self::getAllowedOrigins()))) { //Don't allow CORS from other domains to prevent XSS. 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']); + } } diff --git a/airtime_mvc/application/forms/Login.php b/airtime_mvc/application/forms/Login.php index b8d3989c2..623fa14fa 100644 --- a/airtime_mvc/application/forms/Login.php +++ b/airtime_mvc/application/forms/Login.php @@ -1,5 +1,7 @@ setMethod('post'); - $this->addElement('hash', 'csrf', array( - 'salt' => 'unique' - )); + //If the request comes from an origin we consider safe, we disable the CSRF + //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( array('ViewScript', array('viewScript' => 'form/login.phtml'))