streaming-website/command/download.php

58 lines
1.1 KiB
PHP
Raw Normal View History

<?php
$conf = $GLOBALS['CONFIG']['DOWNLOAD'];
if(isset($conf['REQUIRE_USER']))
{
if(get_current_user() != $conf['require-user'])
{
stderr(
'Not downloading files for user %s, run this script as user %s',
get_current_user(),
$conf['require-user']
);
exit(2);
}
}
2016-12-11 19:27:35 +00:00
$conferences = Conferences::getConferences();
if(isset($conf['MAX_CONFERENCE_AGE']))
{
2016-12-11 19:27:35 +00:00
$months = intval($conf['MAX_CONFERENCE_AGE']);
$conferencesAfter = new DateTime();
$conferencesAfter->sub(new DateInterval('P'.$months.'D'));
stdout('Skipping Conferences before %s', $conferencesAfter->format('Y-m-d'));
2016-12-11 19:27:35 +00:00
$conferences = array_filter($conferences, function($conference) use ($conferencesAfter) {
if($conference->isOpen())
{
stdout(
' %s: %s',
'---open---',
$conference->getSlug()
);
return true;
}
2016-12-11 19:27:35 +00:00
$isBefore = $conference->endsAt() < $conferencesAfter;
if($isBefore) {
stdout(
' %s: %s',
$conference->endsAt()->format('Y-m-d'),
$conference->getSlug()
);
}
2016-12-11 19:27:35 +00:00
return !$isBefore;
});
}
stdout('');
foreach ($conferences as $conference)
{
stdout('== %s ==', $conference->getSlug());
}