Conflicts: .gitignore airtime_mvc/application/Bootstrap.php airtime_mvc/application/configs/conf.php airtime_mvc/application/controllers/SystemstatusController.php airtime_mvc/application/controllers/UpgradeController.php airtime_mvc/application/upgrade/Upgrades.php airtime_mvc/application/views/scripts/systemstatus/index.phtml airtime_mvc/build/airtime.conf airtime_mvc/build/sql/defaultdata.sql airtime_mvc/public/index.php airtime_mvc/tests/application/helpers/AirtimeInstall.php install_minimal/airtime-install install_minimal/include/airtime-constants.php install_minimal/include/airtime-copy-files.sh install_minimal/include/airtime-db-install.php install_minimal/include/airtime-initialize.sh install_minimal/include/airtime-install.php install_minimal/include/airtime-installed-check.php install_minimal/include/airtime-remove-files.sh install_minimal/include/airtime-upgrade.php python_apps/media-monitor/install/media-monitor-copy-files.py python_apps/monit/monit-airtime-generic.cfg python_apps/pypo/airtime-playout python_apps/pypo/install/pypo-copy-files.py python_apps/pypo/liquidsoap/generate_liquidsoap_cfg.py python_apps/pypo/liquidsoap/ls_script.liq python_apps/pypo/pypo/__main__.py python_apps/pypo/pypo/media/update/replaygain.py python_apps/pypo/pypo/media/update/replaygainupdater.py python_apps/pypo/pypo/media/update/silananalyzer.py python_apps/python-virtualenv/airtime_virtual_env.pybundle python_apps/python-virtualenv/requirements utils/airtime-check-system.php
61 lines
2 KiB
PHP
61 lines
2 KiB
PHP
<?php
|
|
|
|
require_once("Upgrades.php");
|
|
|
|
class UpgradeController extends Zend_Controller_Action
|
|
{
|
|
public function indexAction()
|
|
{
|
|
$this->view->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
if (!$this->verifyAuth()) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
$upgradeManager = new UpgradeManager();
|
|
$didWePerformAnUpgrade = $upgradeManager->doUpgrade();
|
|
|
|
if (!$didWePerformAnUpgrade) {
|
|
$this->getResponse()
|
|
->setHttpResponseCode(200)
|
|
->appendBody("No upgrade was performed. The current schema version is " . Application_Model_Preference::GetSchemaVersion() . ".<br>");
|
|
} else {
|
|
$this->getResponse()
|
|
->setHttpResponseCode(200)
|
|
->appendBody("Upgrade to Airtime schema version " . Application_Model_Preference::GetSchemaVersion() . " OK<br>");
|
|
}
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
$this->getResponse()
|
|
->setHttpResponseCode(400)
|
|
->appendBody($e->getMessage());
|
|
}
|
|
}
|
|
|
|
private function verifyAuth()
|
|
{
|
|
//The API key is passed in via HTTP "basic authentication":
|
|
//http://en.wikipedia.org/wiki/Basic_access_authentication
|
|
|
|
$CC_CONFIG = Config::getConfig();
|
|
|
|
//Decode the API key that was passed to us in the HTTP request.
|
|
$authHeader = $this->getRequest()->getHeader("Authorization");
|
|
|
|
$encodedRequestApiKey = substr($authHeader, strlen("Basic "));
|
|
$encodedStoredApiKey = base64_encode($CC_CONFIG["apiKey"][0] . ":");
|
|
|
|
if ($encodedRequestApiKey !== $encodedStoredApiKey)
|
|
{
|
|
$this->getResponse()
|
|
->setHttpResponseCode(401)
|
|
->appendBody("Error: Incorrect API key.<br>");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
}
|