| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | include_once '../../includes/easyparliament/init.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | $offset = 10; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | $from = get_http_var('from'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | $gid = get_http_var('gid'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | $start = intval(get_http_var('start')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | $file = intval(get_http_var('file')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | $pid = intval(get_http_var('pid')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | $gid_safe = _htmlspecialchars($gid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | if (!$gid) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     $this_page = 'video_front'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     $PAGE->page_start(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     $PAGE->stripe_start(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     video_front_page(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     $PAGE->stripe_end(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     $PAGE->page_end(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | $this_page = 'video_main'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | $surrounding_speeches = 3; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | # if ($from == 'next') $surrounding_speeches = 2; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | $gid = "uk.org.publicwhip/$gid"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | # Fetch this GID from the database, and captioner bot time if there is one | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | $db = new ParlDB; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | $q = $db->query("select hdate, htime, adate, atime, hpos, video_status, subsection_id, major, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     (select h.gid from hansard as h where h.epobject_id=hansard.subsection_id) as parent_gid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     (select body from epobject as e where e.epobject_id=hansard.subsection_id) as parent_body | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     from hansard | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     left join video_timestamps on hansard.gid = video_timestamps.gid and user_id = -1 and video_timestamps.deleted = 0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     where hansard.gid = :gid", array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         ':gid' => $gid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | if (!$q->rows()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     $PAGE->error_message('That GID does not appear to exist.', true, 404); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | $video_status = $q->field(0, 'video_status'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | $major = $q->field(0, 'major'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | $hpos = $q->field(0, 'hpos'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | $hdate = $q->field(0, 'hdate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | $htime = $q->field(0, 'htime'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | $atime = $q->field(0, 'atime'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | $adate = $q->field(0, 'adate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | if ($atime) $htime = $atime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | if ($adate) $hdate = $adate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | $parent_gid = str_replace('uk.org.publicwhip/debate/', '/debates/?id=', $q->field(0, 'parent_gid')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | $parent_gid = str_replace('uk.org.publicwhip/lords/', '/lords/?gid=', $parent_gid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | $parent_body = $q->field(0, 'parent_body'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | $parent_epid = $q->field(0, 'subsection_id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | if (!($video_status&1) || ($video_status&8)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     $PAGE->error_message('That GID does not appear to have any video. Please visit the <a href="/video/">video front page</a>.', true, 404); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | # See if we can get a more accurate timestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | $q = $db->query("select adate,atime from video_timestamps, hansard | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     where video_timestamps.gid = hansard.gid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         and (user_id is null or user_id != -1) and deleted = 0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         and hdate='$hdate' and hpos<$hpos and major=$major | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     order by hpos desc limit 1"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | if ($q->rows()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     $adate = $q->field(0, 'adate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     $atime = $q->field(0, 'atime'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     if ($atime > $htime) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $htime = $atime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $offset = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | # Fetch preceding/following speeches data * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | $q = $db->query("select hansard.gid, body, htype, htime, adate, atime, hpos, given_name, family_name, video_status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     from hansard | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         inner join epobject on hansard.epobject_id=epobject.epobject_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         left join member on hansard.person_id=member.person_id AND member.entered_house <= hansard.hdate AND hansard.hdate <= member.left_house AND member.house = 1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         join person_names pn on member.person_id = pn.person_id AND pn.type = 'name' AND pn.start_date <= hansard.hdate AND hansard.hdate <= pn.end_date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                 left join video_timestamps on hansard.gid = video_timestamps.gid and user_id = -1 and video_timestamps.deleted = 0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     where hpos>=$hpos-$surrounding_speeches and hpos<=$hpos+$surrounding_speeches and hdate='$hdate' and major=$major | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     ORDER BY hpos desc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | "); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | $gids_previous = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | $gids_following = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | $gid_actual = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | for ($i=0; $i<$q->rows(); $i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     $row = $q->row($i); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     if ($row['adate']) $row['hdate'] = $row['adate']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     if ($row['atime']) $row['htime'] = $row['atime']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     if ($row['hpos'] < $hpos) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $gids_previous[] = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     } elseif ($row['hpos'] > $hpos) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $gids_following[] = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $gid_actual = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | # Summary of debate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | $q = $db->query("select hansard.gid, body, htype, hpos, person_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     from hansard | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         inner join epobject on hansard.epobject_id=epobject.epobject_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     where subsection_id = $parent_epid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     ORDER BY hpos | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | "); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | $summary = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | for ($i=0; $i<$q->rows(); $i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     $row = $q->row($i); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     $count = count(explode(' ', $row['body'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     $summary .= '<li>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | $row[person_id] : $count words"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | #if (strlen(strip_tags($gid_actual['body'])) > 500) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | #	$gid_actual['body_first'] = '<p>' . substr(strip_tags($gid_actual['body']), 0, 500) . '...'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | #} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     #$gid_actual['body_first'] = $gid_actual['body']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | $gid_actual['body_first'] = preg_replace('#^(<p[^>]*>)([^<]{1,50}[^<\s]*)#s', '$1<strong><big>$2</big></strong>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     preg_replace('#</?phrase[^>]*>#', '', $gid_actual['body'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | #} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | # Work out what video we want, and where in it | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | $videodb = \MySociety\TheyWorkForYou\Utility\Video::dbConnect(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | if (!$videodb) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     $PAGE->error_message('We appear to be having problems connecting to the database of video timings. Sorry, and please try again later.', true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | $video = \MySociety\TheyWorkForYou\Utility\Video::fromTimestamp($videodb, $hdate, $htime); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | if (!$start) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     $start = $video['offset'] - $offset; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | if ($start < 0) $start = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | if (get_http_var('barcamp')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     $video['id'] -= 4000; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | if (!$file) $file = $video['id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | # Start displaying | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | /* | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | if (get_http_var('adv')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     $PAGE->page_start(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     echo '<table id="video_table" border="0" cellspacing="0" cellpadding="5"><tr valign="top"><td width="50%">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     print \MySociety\TheyWorkForYou\Utility\Video::object($file, $start, $gid_safe, 1, $pid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     video_quote($gid_actual, $parent_gid, $parent_body); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     iframe_search($gid_safe, $file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     echo '</td><td>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     advanced_hints($gid_safe, $file, $pid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     previous_speeches($surrounding_speeches, $gids_previous); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     echo '</td>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     echo '</tr></table>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     $PAGE->page_end(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | $PAGE->page_start(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | <script type="text/javascript"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | function hideInstructions() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     document.getElementById('advanced_hints').style.display='block'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     document.getElementById('basic_hints').style.display='none'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     document.cookie = 'hideVideoInt=1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | function showInstructions() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     document.getElementById('basic_hints').style.display='block'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     document.getElementById('advanced_hints').style.display='none'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     document.cookie = 'hideVideoInt=0'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |     return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | </script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     $hidden_int = (isset($_COOKIE['hideVideoInt']) && $_COOKIE['hideVideoInt']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     echo '<table id="video_table" border="0" cellspacing="0" cellpadding="5"><tr valign="top"><td width="50%">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     if ($gid_actual['video_status']&4) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         $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"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         $max = $q->field(0, 'ws'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         echo '<p class="informational">Thanks, but this speech has <strong>already been stamped</strong>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         if ($max < '00:15:00') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |             echo ' <strong>within the last 15 minutes</strong>, so it\'s possible you and someone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | else are timestamping the same debate at the same time'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         } elseif ($from == 'next') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             echo ' (probably by someone coming by at random when you\'ve been clicking Next)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         echo '. You can <a href="/video/next.php?action=nextneeded&gid=', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | $gid_safe, '&file=', $file, '&time=', $start, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | '">go to the next unstamped speech on this day</a>, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | or <a href="/video/next.php?action=random">get a new unstamped speech at random</a>.</p>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     print \MySociety\TheyWorkForYou\Utility\Video::object($file, $start, $gid_safe, 1, $pid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |     video_quote($gid_actual, $parent_gid, $parent_body); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |     if (get_http_var('from') != 'next' || !$hidden_int) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         previous_speeches($surrounding_speeches, $gids_previous); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     # print $summary; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     echo '</td><td>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     echo '<div id="basic_hints"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |     if ($hidden_int) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         echo ' style="display:none"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     echo '>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |     echo '<p style="float: right; border: solid 1px #666666; padding:3px;"><a onclick="return hideInstructions();" href=""><small>Hide instructions</small></a></p>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     basic_instructions($pid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     basic_hints($gid_safe, $file, $pid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     echo '</div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |     echo '<div id="advanced_hints"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     if (!$hidden_int) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         echo ' style="display:none"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     echo '>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     advanced_hints($gid_safe, $file, $pid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     echo '</div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     if (get_http_var('from') == 'next' && $hidden_int) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         previous_speeches($surrounding_speeches, $gids_previous); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         iframe_search($gid_safe, $file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     echo '</td>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |     echo '</tr></table>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     $PAGE->page_end(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | # --- | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 233 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 234 |  |  | function video_front_page() { | 
            
                                                                        
                            
            
                                    
            
            
                | 235 |  |  |     $db = new ParlDB; | 
            
                                                                        
                            
            
                                    
            
            
                | 236 |  |  |     $statuses = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 237 |  |  |         0 => 'Unstamped', | 
            
                                                                        
                            
            
                                    
            
            
                | 238 |  |  |         4 => 'Timestamped by users', | 
            
                                                                        
                            
            
                                    
            
            
                | 239 |  |  |     ); | 
            
                                                                        
                            
            
                                    
            
            
                | 240 |  |  |     $q = $db->query('select video_status&4 as checked,count(*) as c from hansard | 
            
                                                                        
                            
            
                                    
            
            
                | 241 |  |  |     where major=1 and video_status>0 and video_status<8 and video_status!=2 and htype in (12,13) group by video_status&4'); | 
            
                                                                        
                            
            
                                    
            
            
                | 242 |  |  |     $totaliser = array(0=>0, 4=>0); | 
            
                                                                        
                            
            
                                    
            
            
                | 243 |  |  |     for ($i=0; $i<$q->rows(); $i++) { | 
            
                                                                        
                            
            
                                    
            
            
                | 244 |  |  |         $status = $q->field($i, 'checked'); | 
            
                                                                        
                            
            
                                    
            
            
                | 245 |  |  |         $count = $q->field($i, 'c'); | 
            
                                                                        
                            
            
                                    
            
            
                | 246 |  |  |         $totaliser[$status] = $count; | 
            
                                                                        
                            
            
                                    
            
            
                | 247 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 248 |  |  |     $percentage = round($totaliser[4] / ($totaliser[0]+$totaliser[4]) * 10000) / 100; | 
            
                                                                        
                            
            
                                    
            
            
                | 249 |  |  |     $out = "$totaliser[4] timestamped out of " . ($totaliser[0] + $totaliser[4]) . " ($percentage%)" | 
            
                                                                        
                            
            
                                    
            
            
                | 250 |  |  | ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 251 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 252 |  |  | <p style="margin-top:1em"><big>TheyWorkForYou has video of the House of Commons from the BBC, and | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  | the text of Hansard from Parliament. Now we need <strong>your</strong> | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  | help to match up the two.</big></p> | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 256 |  |  | <p>We've written a little Flash app where you can (hopefully) match up the written speech being displayed to | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  | what's playing on the video. We'll then store your results and use them to put the video, | 
            
                                                                        
                            
            
                                    
            
            
                | 258 |  |  | timestamped to the right location, on the relevant page of TheyWorkForYou.</p> | 
            
                                                                        
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 260 |  |  | <p>If you're a registered user and logged in, | 
            
                                                                        
                            
            
                                    
            
            
                | 261 |  |  | your timestampings will appear in our chart below – there may be prizes for best timestampers… :) | 
            
                                                                        
                            
            
                                    
            
            
                | 262 |  |  | Registration is not needed to timestamp videos, but you can <a href="/user/?pg=join&ret=/video/">register here</a> if you want.</p> | 
            
                                                                        
                            
            
                                    
            
            
                | 263 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 264 |  |  | <p id="video_attract"><?php | 
            
                                                                        
                            
            
                                    
            
            
                | 265 |  |  |     if ($totaliser[0]) { | 
            
                                                                        
                            
            
                                    
            
            
                | 266 |  |  |         echo '<a href="next.php?action=random">Give me a random speech that needs timestamping</a>'; | 
            
                                                                        
                            
            
                                    
            
            
                | 267 |  |  |     } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 268 |  |  |         echo 'Wow, everything that can currently be timestamped appears to have been, thanks!'; | 
            
                                                                        
                            
            
                                    
            
            
                | 269 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 270 |  |  | ?></p> | 
            
                                                                        
                            
            
                                    
            
            
                | 271 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 272 |  |  | <div id="top" style="float: left; width: 45%;"> | 
            
                                                                        
                            
            
                                    
            
            
                | 273 |  |  | <?php | 
            
                                                                        
                            
            
                                    
            
            
                | 274 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 275 |  |  |     list($out_today, $rank_today) = display_league(20, 'and date(whenstamped)=current_date'); | 
            
                                                                        
                            
            
                                    
            
            
                | 276 |  |  |     list($out_week, $rank_week) = display_league(40, 'and date(whenstamped)>current_date-interval 28 day'); | 
            
                                                                        
                            
            
                                    
            
            
                | 277 |  |  |     list($out_overall, $rank_overall) = display_league(100); | 
            
                                                                        
                            
            
                                    
            
            
                | 278 |  |  |     $out_overall = ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 280 |  |  |     global $THEUSER; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 281 |  |  |     if ($THEUSER->user_id() && ($rank_today || $rank_week || $rank_overall)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 282 |  |  |         echo '<p align="center"><big>You are '; | 
            
                                                                        
                            
            
                                    
            
            
                | 283 |  |  |         if ($rank_today) echo make_ranking($rank_today), ' today, '; | 
            
                                                                        
                            
            
                                    
            
            
                | 284 |  |  |         if ($rank_week) echo make_ranking($rank_week), ' last 4 weeks, '; | 
            
                                                                        
                            
            
                                    
            
            
                | 285 |  |  |         if ($rank_overall) echo make_ranking($rank_overall), ' overall'; | 
            
                                                                        
                            
            
                                    
            
            
                | 286 |  |  |         echo '</big></p>'; | 
            
                                                                        
                            
            
                                    
            
            
                | 287 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 288 |  |  |     if ($out_today) echo "<h3>Top timestampers (today)</h3> <ol>$out_today</ol>"; | 
            
                                                                        
                            
            
                                    
            
            
                | 289 |  |  |     if ($out_week) echo "<h3>Top timestampers (last 4 weeks)</h3> <ol>$out_week</ol>"; | 
            
                                                                        
                            
            
                                    
            
            
                | 290 |  |  |     if ($out_overall) echo "<h3>Top timestampers (overall)</h3> <ol>$out_overall</ol>"; | 
            
                                                                        
                            
            
                                    
            
            
                | 291 |  |  |     echo '</div>'; | 
            
                                                                        
                            
            
                                    
            
            
                | 292 |  |  | ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 293 |  |  | <div style="float: right; width: 50%"> | 
            
                                                                        
                            
            
                                    
            
            
                | 294 |  |  | <img align="right" width=200 height=100 src="http://chart.apis.google.com/chart?chs=200x100&cht=gom&chd=t:<?=$percentage?>" alt="<?=$percentage?>% of speeches have been timestamped"> | 
            
                                                                        
                            
            
                                    
            
            
                | 295 |  |  | <h3>Totaliser</h3> | 
            
                                                                        
                            
            
                                    
            
            
                | 296 |  |  | <ul><?=$out?></ul> | 
            
                                                                        
                            
            
                                    
            
            
                | 297 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 298 |  |  | <?php | 
            
                                                                        
                            
            
                                    
            
            
                | 299 |  |  |     $q = $db->query('select video_status&4 as checked,count(*) as c from hansard | 
            
                                                                        
                            
            
                                    
            
            
                | 300 |  |  |     where major=1 and video_status>0 and video_status<8 and video_status!=2 and htype in (12,13) | 
            
                                                                        
                            
            
                                    
            
            
                | 301 |  |  |         and hdate=(select max(hdate) from hansard where major=1) | 
            
                                                                        
                            
            
                                    
            
            
                | 302 |  |  |     group by video_status&4'); | 
            
                                                                        
                            
            
                                    
            
            
                | 303 |  |  |     $totaliser = array(0=>0, 4=>0); | 
            
                                                                        
                            
            
                                    
            
            
                | 304 |  |  |     for ($i=0; $i<$q->rows(); $i++) { | 
            
                                                                        
                            
            
                                    
            
            
                | 305 |  |  |         $status = $q->field($i, 'checked'); | 
            
                                                                        
                            
            
                                    
            
            
                | 306 |  |  |         $count = $q->field($i, 'c'); | 
            
                                                                        
                            
            
                                    
            
            
                | 307 |  |  |         $totaliser[$status] = $count; | 
            
                                                                        
                            
            
                                    
            
            
                | 308 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 309 |  |  |     $total_possible = $totaliser[0] + $totaliser[4]; | 
            
                                                                        
                            
            
                                    
            
            
                | 310 |  |  |     if ($total_possible == 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 311 |  |  |         $percentage = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 312 |  |  |         $out = 'Nothing possible to timestamp on most recent day'; | 
            
                                                                        
                            
            
                                    
            
            
                | 313 |  |  |     } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 314 |  |  |         $percentage = round($totaliser[4] / $total_possible * 10000) / 100; | 
            
                                                                        
                            
            
                                    
            
            
                | 315 |  |  |         $out = "$totaliser[4] timestamped out of $total_possible ($percentage%)"; | 
            
                                                                        
                            
            
                                    
            
            
                | 316 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 318 |  |  | ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 319 |  |  | <h3 style="padding-top:0.5em;clear:right">Totaliser for most recent day</h3> | 
            
                                                                        
                            
            
                                    
            
            
                | 320 |  |  | <img align="right" width=200 height=100 src="http://chart.apis.google.com/chart?chs=200x100&cht=gom&chd=t:<?=$percentage?>" alt="<?=$percentage?>% of speeches have been timestamped"> | 
            
                                                                        
                            
            
                                    
            
            
                | 321 |  |  | <ul><?=$out?></ul> | 
            
                                                                        
                            
            
                                    
            
            
                | 322 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 323 |  |  | <h3 style="clear:both;margin-top:1em">Latest stamped</h3> | 
            
                                                                        
                            
            
                                    
            
            
                | 324 |  |  | <ul> | 
            
                                                                        
                            
            
                                    
            
            
                | 325 |  |  | <?php | 
            
                                                                        
                            
            
                                    
            
            
                | 326 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 327 |  |  |     $q = $db->query('select hansard.gid, body, major from video_timestamps, hansard, epobject | 
            
                                                                        
                            
            
                                    
            
            
                | 328 |  |  |     where (user_id != -1 or user_id is null) and video_timestamps.deleted=0 | 
            
                                                                        
                            
            
                                    
            
            
                | 329 |  |  |         and video_timestamps.gid = hansard.gid and hansard.subsection_id = epobject.epobject_id | 
            
                                                                        
                            
            
                                    
            
            
                | 330 |  |  |     order by whenstamped desc limit 20'); | 
            
                                                                        
                            
            
                                    
            
            
                | 331 |  |  |     for ($i=0; $i<$q->rows(); $i++) { | 
            
                                                                        
                            
            
                                    
            
            
                | 332 |  |  |         $gid = $q->field($i, 'gid'); | 
            
                                                                        
                            
            
                                    
            
            
                | 333 |  |  |         $body = $q->field($i, 'body'); | 
            
                                                                        
                            
            
                                    
            
            
                | 334 |  |  |         if ($q->field($i, 'major') == 101) { | 
            
                                                                        
                            
            
                                    
            
            
                | 335 |  |  |             $url = '/lords/?gid='; | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 337 |  |  |             $url = '/debate/?id='; | 
            
                                                                        
                            
            
                                    
            
            
                | 338 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 339 |  |  |         echo '<li><a href="', $url, fix_gid_from_db($gid) . '">' . $body . '</a>'; | 
            
                                                                        
                            
            
                                    
            
            
                | 340 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 341 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  |     echo '</ul></div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | function display_league($limit, $q = '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |     global $THEUSER; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |     $db = new ParlDB; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |     $q = $db->query('select firstname,lastname,video_timestamps.user_id,count(*) as c | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         from video_timestamps left join users on video_timestamps.user_id=users.user_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |         where video_timestamps.deleted=0 and (video_timestamps.user_id is null or video_timestamps.user_id!=-1) ' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         . $q . ' group by user_id order by c desc' . ($THEUSER->user_id() ? '' : " limit $limit") ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |     $out = ''; $rank = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |     for ($i=0; $i<$q->rows(); $i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         $name = $q->field($i, 'firstname') . ' ' . $q->field($i, 'lastname'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         $user_id = $q->field($i, 'user_id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |         #if ($user_id == -1) continue; # $name = 'CaptionerBot'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |         if ($user_id == 0) $name = 'Anonymous'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |         $count = $q->field($i, 'c'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |         if ($THEUSER->user_id() == $user_id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |             $rank = $i+1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |         if ($i>=$limit) continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |         $out .= '<li>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |         if ($THEUSER->user_id() == $user_id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |             $out .= '<strong>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |         $out .= "$name : $count"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |         if ($THEUSER->user_id() == $user_id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |             $out .= '</strong>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         #if ($user_id == -1) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |         #	echo ' <small>(initial run program that tries to guess timestamp from captions, wildly variable)</small>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         #} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |     return array($out, $rank); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | function video_quote($gid_actual, $parent_gid, $parent_body) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |     #echo '<h4>Press “Play”, then click “Now!” when you hear:</h4>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |     echo '<div id="video_quote">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |     echo '<span class="video_name">' . $gid_actual['given_name'] . ' ' . $gid_actual['family_name'] . '</span> '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |     echo $gid_actual['body_first']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |     echo '<p align="right">— from debate entitled “<a title="View entire debate" href="' . $parent_gid . '">' . $parent_body . '</a>”</p>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |     echo '</div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | function basic_instructions($pid) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |     $pid_url = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |     if ($pid) $pid_url = "&pid=$pid"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | <ol style="font-size: 150%;"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | <li>Have a quick scan of the speech under the video, then press “Play”. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | <li>When you hear the start of that speech, press “Now!”. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | <li>The timestamped video will then appear on TheyWorkForYou – thanks from | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | everyone who uses the site :) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | </ol> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | <p style="font-size: 125%; margin: 1em 0; background-color: #ffffcc; padding: 5px;"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | Some videos will be miles out – if you can't | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | find the right point, don't worry, just <a href="/video/next.php?action=random<?=$pid_url?>"><strong>try another speech</strong></a>! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | </p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | function basic_hints($gid_safe, $file, $pid) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |     global $THEUSER; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |     $pid_url = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |     if ($pid) $pid_url = "&pid=$pid"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | <ul> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | <?php	if (!$THEUSER->loggedin()) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | <li><a href="/user/login/?ret=/video/"><strong>Sign in</strong></a> if you want to get on the <a href="/video/#top">Top Timestampers league table</a>! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | <?php	} ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | <li>If the video suddenly <strong>jumps</strong> a couple of hours, or otherwise appears broken, <a href="mailto:<?=str_replace('@', '@', CONTACTEMAIL) ?>?subject=Video%20<?=$file?>%20for%20ID%20<?=$gid_safe?>%20broken">let us know</a>. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | <li>If the speech you're looking for is <strong>beyond the end</strong> of the video, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | <a href="/video/?gid=<?=$gid_safe?>&file=<?=$file+1?>&start=1<?=$pid_url?>">move on to the next video chunk</a>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | <li>If you're right at the start of a day, it's quite possible the start of the video | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | will be the end of the previous programme on BBC Parliament, skip ahead some minutes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | to check :) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | <li>Hansard is not a verbatim transcript, so <strong>spoken words might | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | differ</strong> slightly from the printed version. And a small note – if | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | the speech you are looking out for is an oral question (questions asked in the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | first hour or so of Monday–Thursdays in the Commons), then all the MP | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | will actually say is their question number, e.g.  “Number Two”. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | <li>The skip buttons move in 30 second increments (you can go | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | back before the start point), and you can access a slider by hovering | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | over the video. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | </ul> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | <p align="right"><small><b>Credits:</b> Video from <a href='http://www.bbc.co.uk/parliament/'>BBC Parliament</a> and mySociety</small></p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | function advanced_hints($gid_safe, $file, $pid) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |     global $THEUSER; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |     $pid_url = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |     if ($pid) $pid_url = "&pid=$pid"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | <p align="center">Actions: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | <a href="/video/next.php?action=random">Skip</a> | | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | <?php	if (!$THEUSER->loggedin()) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | <a href="/user/login/?ret=/video/">Log in</a> | | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | <?php	} ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | <a href="mailto:<?=str_replace('@', '@', CONTACTEMAIL) ?>?subject=Video%20<?=$file?>%20for%20ID%20<?=$gid_safe?>%20broken">Broken video</a> | | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | <a href="/video/?gid=<?=$gid_safe?>&file=<?=$file+1?>&start=1<?=$pid_url?>" title="Loads the next video chunk">Speech past end of video</a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | </p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | <p align="right"><small><!-- <b>Credits:</b> Video from <a href='http://www.bbc.co.uk/parliament/'>BBC Parliament</a> and mySociety. --> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | <a style=" border: solid 1px #666666; padding:3px;" onclick="return showInstructions();" href="">Show all instructions</a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | </small></p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | function iframe_search($gid_safe, $file) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | <iframe frameborder=0 style="border: dotted 1px black; margin-top:0.5em" name="video_person_search" width="95%" height="800" src="distance.php?gid=<?=$gid_safe?>&file=<?=$file?>"></iframe> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | function previous_speeches($surrounding_speeches, $gids_previous) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |     echo '<h3 style="margin-top:1em">The three speeches/headings immediately before</h3> <ol class="otherspeeches">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |     $ccc = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |     foreach ($gids_previous as $row) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |         disp_speech($row, $ccc++); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |     echo '</ol>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | function disp_speech($row, $count) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |     echo '<li'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |     if ($row['htype']==13) echo ' class="unspoken"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |     elseif ($row['htype']<12) echo ' class="heading"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |     if (!($count%2)) echo ' style="background-color: #F5FDEA;"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |     else echo ' style="background-color: #E8FDCB;"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |     echo '>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |     if ($count) echo "<em>$count earlier:</em> "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |     if ($row['htype']==12) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |         echo '<span class="video_name">' . $row['given_name'] . ' ' . $row['family_name'] . '</span> '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |     echo $row['body']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |     echo '</li>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | echo '<h3>The '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | if ($gid_actual['body'] != $gid_actual['body_first']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |     echo' whole'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | echo ' speech you\'re looking out for</h3>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | echo $gid_actual['body']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | echo '<h3 style="margin-top:1em">Following speeches/headings</h3> <ol class="otherspeeches">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | foreach ($gids_following as $row) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |     disp_speech($row, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | echo '</ul>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | /* | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | $last_prev = end($gids_previous); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | if ($last_prev['htime'] == $gid_actual['htime']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |     echo "<p><small><em>This speech has the same timestamp as the previous speech, so might well be inaccurate.</em></small></p>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 506 |  |  | */ | 
            
                                                        
            
                                    
            
            
                | 507 |  |  |  | 
            
                        
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.