Exemplo n.º 1
0
 function buildSchedule($f3)
 {
     $db = $f3->get('db');
     // Load Videos
     $videos = new Db\SQL\Mapper($f3->get('db'), 'videos');
     $videos = $videos->find(array('channel=?', $f3->get('PARAMS.channelID')));
     // Clear Existing Schedule
     $db->exec('DELETE FROM schedule WHERE channel=?', $f3->get('PARAMS.channelID'));
     // Shuffle Playlist
     shuffle($videos);
     // Build Schedule
     $schedule = new Db\SQL\Mapper($f3->get('db'), 'schedule');
     $time = time();
     foreach ($videos as $video) {
         $schedule->reset();
         $schedule->channel = $f3->get('PARAMS.channelID');
         $schedule->video = $video->id;
         $schedule->startTime = $time;
         $time += $video->endTime - $video->startTime;
         $schedule->endTime = $time;
         $schedule->save();
     }
     return count($videos);
 }
Exemplo n.º 2
0
$f3 = (require 'vendor/bcosca/fatfree/base.php');
$f3->config('config.cfg');
require 'video.php';
require 'channel.php';
require 'user.php';
$f3->set('DEBUG', 1);
$f3->set('db', new DB\SQL('sqlite:' . $f3->get('DATABASE_FILE')));
$f3->set('CACHE', true);
// Required For Sessions
new Session();
if ($f3->get('ALLOW_EMBED')) {
    $f3->set('XFRAME', 0);
}
$f3->route('GET /', function ($f3) {
    // Get Channels
    $channels = new Db\SQL\Mapper($f3->get('db'), 'channels');
    $f3->set('channels', $channels->find());
    echo Template::instance()->render('templates/index.html');
});
$f3->route('GET /channel/@channelID/status', 'Channel->status');
if (!$f3->get('READ_ONLY')) {
    if (!$f3->get('LOGIN') || $f3->get('SESSION')) {
        $f3->route('GET @channelList: /channels', 'Channel->viewAll');
        $f3->route('GET /channel/new', 'Channel->addForm');
        $f3->route('POST /channel/new', 'Channel->add');
        $f3->route('GET @channelEdit: /channel/@channelID/edit', 'Channel->editForm');
        $f3->route('POST /channel/@channelID/edit', 'Channel->edit');
        $f3->route('GET /channel/@channelID/new', 'Video->addForm');
        $f3->route('POST /channel/@channelID/new', 'Video->add');
        $f3->route('GET /channel/@channelID/@videoID', 'Video->editForm');
        $f3->route('POST /channel/@channelID/@videoID', 'Video->edit');