Пример #1
0
        echo '<p>You appear to have reached the end of the day (or
everything after where you have just done has already been stamped).
Congratulations, now <a href="/video/">get stuck in somewhere else</a>!
;-)</p>';
        $PAGE->stripe_end();
        $PAGE->page_end();
    } else {
        $new_gid = $q->field(0, 'gid');
        $new_hpos = $q->field(0, 'hpos');
        if ($action == 'nextneeded') {
            $q = $db->query("select adate, atime from hansard, video_timestamps\n                where hansard.gid = video_timestamps.gid and deleted=0\n                    and hpos<{$new_hpos} and hdate='{$hdate}' and major={$major}\n                    and (htype=12 or htype=13) and (user_id is null or user_id!=-1)\n                order by hpos desc limit 1");
            $adate = $q->field(0, 'adate');
            $atime = $q->field(0, 'atime');
            $videodb = \MySociety\TheyWorkForYou\Utility\Video::dbConnect();
            if ($videodb) {
                $video = \MySociety\TheyWorkForYou\Utility\Video::fromTimestamp($videodb, $adate, $atime);
                $file = $video['id'];
                $time = $video['offset'];
            }
        }
        $new_gid = fix_gid_but_leave_section($new_gid);
        header('Location: /video/?from=next&file=' . $file . '&gid=' . $new_gid . '&start=' . $time);
    }
} elseif ($action == 'random' && $pid) {
    $db = new ParlDB();
    $q = $db->query("select gid from hansard\n        where video_status in (1,3) and major=:major\n        and (htype=12 or htype=13)\n        and hansard.person_id=:pid\n        ORDER BY RAND() LIMIT 1", array(':major' => $major, ':pid' => $pid));
    $new_gid = fix_gid_but_leave_section($q->field(0, 'gid'));
    header('Location: /video/?from=random&pid=' . $pid . '&gid=' . $new_gid);
} elseif ($action == 'random') {
    $db = new ParlDB();
    $q = $db->query("select gid, hpos, hdate from hansard\n        where video_status in (1,3) and major=:major\n        and (htype=12 or htype=13)\n        ORDER BY RAND() LIMIT 1", array(':major' => $major));
Пример #2
0
<?php

include_once "../www/includes/easyparliament/init.php";
$db = new ParlDB();
$videodb = \MySociety\TheyWorkForYou\Utility\Video::dbConnect();
$q = pg_query($videodb, "\n    SELECT id, broadcast_start, broadcast_end\n    FROM programmes\n    WHERE channel_id = 'BBCParl' AND status = 'available'\n    ORDER BY id\n");
while ($row = pg_fetch_array($q)) {
    date_default_timezone_set('GMT');
    $start = strtotime($row['broadcast_start']);
    $end = strtotime($row['broadcast_end']);
    date_default_timezone_set('Europe/London');
    $start_date = date('Y-m-d', $start);
    $start_time = date('H:i:s', $start);
    $end_date = date('Y-m-d', $end);
    $end_time = date('H:i:s', $end);
    if ($start_date == $end_date) {
        $qq = $db->query("update hansard set video_status = video_status | 1\n\t    where hdate='{$start_date}' and htime>='{$start_time}' and htime<'{$end_time}' and major=1");
    } else {
        $qq = $db->query("update hansard set video_status = video_status | 1\n\t    where ((hdate='{$start_date}' and htime>='{$start_time}')\n\t       or (hdate='{$end_date}' and htime<'{$end_time}')) and major=1");
    }
    #print "$start - $end : " . $qq->affected_rows() . "\n";
}
Пример #3
0
 private function video_sidebar($row, $heading_hpos, $count)
 {
     $db = new \ParlDB();
     $gid_type = $this->video_gid_type();
     $vq = $db->query("select id,adate,atime from video_timestamps where gid='uk.org.publicwhip/{$gid_type}/{$row['gid']}' and (user_id!=-1 or user_id is null) and deleted=0 order by (user_id is null) limit 1");
     $adate = $vq->field(0, 'adate');
     $time = $vq->field(0, 'atime');
     $videodb = \MySociety\TheyWorkForYou\Utility\Video::dbConnect();
     if (!$videodb) {
         return '';
     }
     $video = \MySociety\TheyWorkForYou\Utility\Video::fromTimestamp($videodb, $adate, $time);
     $start = $video['offset'];
     $out = '';
     if ($count > 1) {
         $out .= '<div class="debate__video" id="video_wrap"><div>';
         if ($row['gid'] != $this->first_gid) {
             $out .= '<p class="video-instructions">This video starts around ' . ($row['hpos'] - $heading_hpos) . ' speeches in (<a href="#g' . gid_to_anchor($row['gid']) . '">move there in text</a>)</p>';
         }
     }
     $out .= \MySociety\TheyWorkForYou\Utility\Video::object($video['id'], $start, "{$gid_type}/{$row['gid']}");
     $flashvars = 'gid=' . "{$gid_type}/{$row['gid']}" . '&amp;file=' . $video['id'] . '&amp;start=' . $start;
     $out .= "<strong>Embed this video</strong><p class='video-instructions'>Copy and paste this code on your website</p><input readonly onclick='this.focus();this.select();' type='text' name='embed' size='40' value=\"<embed src='http://www.theyworkforyou.com/video/parlvid.swf' width='320' height='230' allowfullscreen='true' allowscriptaccess='always' flashvars='{$flashvars}'></embed>\">";
     if ($count > 1) {
         $out .= '<p class="hide-video"><a href="" onclick="return showVideo();">Hide</a></p>';
         $out .= '</div></div>';
         $out .= '<div id="video_show" class="show-video" style="display:none;">
 <p style="margin:0"><a href="" onclick="return hideVideo();">Show video</a></p></div>';
     }
     return $out;
 }
Пример #4
0
}
$start = date('H:i:s', strtotime($video['broadcast_start'] . ' GMT'));
$end = date('H:i:s', strtotime($video['broadcast_end'] . ' GMT'));
$q = $db->query("select video_timestamps.gid, adate, atime, time_to_sec(timediff(atime, '{$start}')) as timediff,\n        time_to_sec(timediff(atime, '{$end}')) as timetoend\n    from hansard, video_timestamps\n    where hansard.gid = video_timestamps.gid and subsection_id={$subsection_id}\n    and (user_id is null or user_id!=-1) and deleted=0 order by atime, hpos");
header('Content-Type: text/xml');
$gids = array();
$file_offset = 0;
print '<stamps>';
for ($i = 0; $i < $q->rows(); $i++) {
    $gid = str_replace('uk.org.publicwhip/', '', $q->field($i, 'gid'));
    if (isset($gids[$gid])) {
        continue;
    }
    $timetoend = $q->field($i, 'timetoend') - $file_offset;
    if ($timetoend > 0) {
        $video = \MySociety\TheyWorkForYou\Utility\Video::fromTimestamp($videodb, $q->field($i, 'adate'), $q->field($i, 'atime'));
        $new_start = date('H:i:s', strtotime($video['broadcast_start'] . ' GMT'));
        $file_offset += timediff($new_start, $start);
        $start = $new_start;
        $end = date('H:i:s', strtotime($video['broadcast_end'] . ' GMT'));
    }
    $timediff = $q->field($i, 'timediff') - $file_offset;
    if ($timediff >= 0) {
        print "<stamp><gid>{$gid}</gid><file>{$video['id']}</file><time>{$timediff}</time></stamp>\n";
    }
    $gids[$gid] = true;
}
print '</stamps>';
function timediff($a, $b)
{
    return substr($a, 0, 2) * 3600 + substr($a, 3, 2) * 60 + substr($a, 6, 2) - substr($b, 0, 2) * 3600 - substr($b, 3, 2) * 60 - substr($b, 6, 2);
Пример #5
0
$hidden_int = isset($_COOKIE['hideVideoInt']) && $_COOKIE['hideVideoInt'];
echo '<table id="video_table" border="0" cellspacing="0" cellpadding="5"><tr valign="top"><td width="50%">';
if ($gid_actual['video_status'] & 4) {
    $q = $db->query("select timediff(current_timestamp,max(whenstamped)) as ws from video_timestamps where gid='{$q_gid}' and (user_id is null or user_id != -1) and deleted=0");
    $max = $q->field(0, 'ws');
    echo '<p class="informational">Thanks, but this speech has <strong>already been stamped</strong>';
    if ($max < '00:15:00') {
        echo ' <strong>within the last 15 minutes</strong>, so it\'s possible you and someone
else are timestamping the same debate at the same time';
    } elseif ($from == 'next') {
        echo ' (probably by someone coming by at random when you\'ve been clicking Next)';
    }
    echo '. You can <a href="/video/next.php?action=nextneeded&amp;gid=', $gid_safe, '&amp;file=', $file, '&amp;time=', $start, '">go to the next unstamped speech on this day</a>,
or <a href="/video/next.php?action=random">get a new unstamped speech at random</a>.</p>';
}
print \MySociety\TheyWorkForYou\Utility\Video::object($file, $start, $gid_safe, 1, $pid);
video_quote($gid_actual, $parent_gid, $parent_body);
if (get_http_var('from') != 'next' || !$hidden_int) {
    previous_speeches($surrounding_speeches, $gids_previous);
}
# print $summary;
echo '</td><td>';
echo '<div id="basic_hints"';
if ($hidden_int) {
    echo ' style="display:none"';
}
echo '>';
echo '<p style="float: right; border: solid 1px #666666; padding:3px;"><a onclick="return hideInstructions();" href=""><small>Hide instructions</small></a></p>';
basic_instructions($pid);
basic_hints($gid_safe, $file, $pid);
echo '</div>';