Merge branch 'cc-5709-airtime-analyzer' of github.com:sourcefabric/Airtime into cc-5709-airtime-analyzer
This commit is contained in:
commit
4d1843ca1f
|
@ -28,7 +28,8 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
|
|||
->add(new Zend_Acl_Resource('usersettings'))
|
||||
->add(new Zend_Acl_Resource('audiopreview'))
|
||||
->add(new Zend_Acl_Resource('webstream'))
|
||||
->add(new Zend_Acl_Resource('locale'));
|
||||
->add(new Zend_Acl_Resource('locale'))
|
||||
->add(new Zend_Acl_Resource('upgrade'));
|
||||
|
||||
/** Creating permissions */
|
||||
$ccAcl->allow('G', 'index')
|
||||
|
@ -42,6 +43,7 @@ $ccAcl->allow('G', 'index')
|
|||
->allow('G', 'audiopreview')
|
||||
->allow('G', 'webstream')
|
||||
->allow('G', 'locale')
|
||||
->allow('G', 'upgrade')
|
||||
->allow('H', 'preference', 'is-import-in-progress')
|
||||
->allow('H', 'usersettings')
|
||||
->allow('H', 'plupload')
|
||||
|
|
|
@ -25,6 +25,11 @@ class PluploadController extends Zend_Controller_Action
|
|||
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'css/plupload.queue.css?'.$CC_CONFIG['airtime_version']);
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'css/addmedia.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
||||
$this->view->quotaLimitReached = false;
|
||||
if (Application_Model_Systemstatus::isDiskOverQuota()) {
|
||||
$this->view->quotaLimitReached = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function recentUploadsAction()
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
class UpgradeController extends Zend_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$airtime_upgrade_version = '2.5.3';
|
||||
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
if (!$this->verifyAuth()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->verifyAirtimeVersion()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Begin upgrade
|
||||
$filename = "/etc/airtime/airtime.conf";
|
||||
$values = parse_ini_file($filename, true);
|
||||
|
||||
$username = $values['database']['dbuser'];
|
||||
$password = $values['database']['dbpass'];
|
||||
$host = $values['database']['host'];
|
||||
$database = $values['database']['dbname'];
|
||||
$dir = __DIR__;
|
||||
|
||||
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_$airtime_upgrade_version/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
|
||||
|
||||
$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("Upgrade to Airtime 2.5.3 OK");
|
||||
}
|
||||
|
||||
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.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function verifyAirtimeVersion()
|
||||
{
|
||||
$pref = CcPrefQuery::create()
|
||||
->filterByKeystr('system_version')
|
||||
->findOne();
|
||||
$airtime_version = $pref->getValStr();
|
||||
|
||||
if ($airtime_version != '2.5.2') {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody("Upgrade to Airtime 2.5.3 FAILED. You must be using Airtime 2.5.2 to upgrade.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -117,7 +117,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
|
|||
return;
|
||||
}
|
||||
|
||||
if (in_array($controller, array("api", "auth", "locale"))) {
|
||||
if (in_array($controller, array("api", "auth", "locale", "upgrade"))) {
|
||||
|
||||
$this->setRoleName("G");
|
||||
} elseif (!Zend_Auth::getInstance()->hasIdentity()) {
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
DELETE FROM cc_pref WHERE keystr = 'system_version';
|
||||
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.5.3');
|
||||
|
||||
ALTER TABLE cc_files DROP COLUMN state;
|
||||
ALTER TABLE cc_files ADD import_status integer default 1; -- Default is "pending"
|
||||
UPDATE cc_files SET import_status=0; -- Existing files are already "imported"
|
|
@ -235,4 +235,16 @@ class Application_Model_Systemstatus
|
|||
|
||||
return array_values($partitions);
|
||||
}
|
||||
|
||||
public static function isDiskOverQuota()
|
||||
{
|
||||
$diskInfo = self::GetDiskInfo();
|
||||
$diskInfo = $diskInfo[0];
|
||||
$diskUsage = $diskInfo->totalSpace - $diskInfo->totalFreeSpace;
|
||||
if ($diskUsage >= $diskInfo->totalSpace) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//If we do get an ID on a POST, then that doesn't make any sense
|
||||
//since POST is only for creating.
|
||||
if ($id = $this->_getParam('id', false)) {
|
||||
|
@ -120,6 +120,13 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
return;
|
||||
}
|
||||
|
||||
if (Application_Model_Systemstatus::isDiskOverQuota()) {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody("ERROR: Disk Quota reached.");
|
||||
return;
|
||||
}
|
||||
|
||||
$file = new CcFiles();
|
||||
$whiteList = $this->removeBlacklistedFieldsFromRequestData($this->getRequest()->getPost());
|
||||
|
||||
|
|
|
@ -2,8 +2,15 @@
|
|||
#plupload_files input[type="file"] {
|
||||
font-size: 200px !important;
|
||||
}
|
||||
</style>
|
||||
<form id="plupload_form">
|
||||
</style>
|
||||
<?php if ($this->quotaLimitReached) { ?>
|
||||
<div class="errors quota-reached">
|
||||
Disk quota exceeded. You cannot upload files until you <a href="http://www.sourcefabric.org/en/airtime" target="_blank">upgrade your storage</a>.
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<form id="plupload_form" <?php if ($this->quotaLimitReached) { ?> class="hidden" <?php } ?>>
|
||||
<div id="plupload_files"></div>
|
||||
</form>
|
||||
<div id="plupload_error">
|
||||
|
|
|
@ -3087,3 +3087,5 @@ dd .stream-status {
|
|||
#popup-share-link {
|
||||
width: 320px;
|
||||
}
|
||||
.quota-reached {
|
||||
font-size: 14px !important;
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
<?php
|
||||
|
||||
// Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../../install_minimal/../airtime_mvc/application'));
|
||||
//include index.php so we can use propel classes
|
||||
require_once APPLICATION_PATH.'/../public/index.php';
|
||||
|
||||
require_once 'DbUpgrade.php';
|
||||
require_once 'StorageQuotaUpgrade.php';
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ post_file() {
|
|||
#path to specific instance's airtime.conf
|
||||
instance_conf_path=$base_instance_path$instance_path$airtime_conf_path
|
||||
|
||||
api_key=$(sudo awk -F "=" '/api_key/ {print $2}' $instance_conf_path)
|
||||
api_key=$(awk -F "= " '/api_key/ {print $2}' $instance_conf_path)
|
||||
|
||||
until curl --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}" -F "name=${filename}"
|
||||
do
|
||||
|
|
Loading…
Reference in New Issue