Index: branches/MetavidWiki-exp/MetavidWiki/maintenance/download_from_archive_org.php |
— | — | @@ -34,25 +34,31 @@ |
35 | 35 | while($stream = $dbr->fetchObject($result) ){ |
36 | 36 | $local_fl = MV_DOWNLOAD_DIR . $stream->name.'.flv'; |
37 | 37 | $remote_fl = MV_ARCHIVE_ORG_DL . $stream->name.'/'.$stream->name.'.flv'; |
| 38 | + //lets just skip local files for now and try to remove incomplete mannually |
38 | 39 | |
39 | | - if(remotefsize($remote_fl)<100000){ |
40 | | - print "remote file: $remote_fl < 100k (skipping) \n"; |
41 | | - continue; |
42 | | - } |
| 40 | + |
43 | 41 | //senate_proceeding_08-01-07/senate_proceeding_08-01-07.flv |
44 | 42 | //check local file size matches remote: |
45 | 43 | if(is_file($local_fl)){ |
46 | | - print "file $local_fl present"; |
47 | | - if( filesize($local_fl)!=remotefsize($remote_fl)){ |
48 | | - echo ' local:'. formatbytes(filesize($local_fl)). |
49 | | - ' != remote:' . formatbytes(remotefsize($remote_fl))."\n"; |
50 | | - echo 'attempting to resume: ' . "\n"; |
51 | | - curldownload($remote_fl, $local_fl); |
| 44 | + print "file $local_fl present (skipping size check)\n"; |
| 45 | + /*if( filesize($local_fl)!=remotefsize($remote_fl)){ |
| 46 | + echo ' local:'. hr_bytes(filesize($local_fl)). |
| 47 | + ' != remote:' . hr_bytes(remotefsize($remote_fl))."\n"; |
| 48 | + echo '(skipping): ' . "\n"; |
| 49 | + //curldownload($remote_fl, $local_fl); |
52 | 50 | }else{ |
53 | | - echo ' sizes match: ' . formatbytes(filesize($local_fl)) .'='. |
54 | | - formatbytes(remotefsize($remote_fl))."\n"; |
55 | | - } |
| 51 | + echo ' sizes match: ' . hr_bytes(filesize($local_fl)) .'='. |
| 52 | + hr_bytes(remotefsize($remote_fl))."\n"; |
| 53 | + }*/ |
56 | 54 | }else{ |
| 55 | + //check if flash file exists: |
| 56 | + //$sql ="SELECT * FROM `mv_stream_files` WHERE `stream_id`=" .$stream->id |
| 57 | + //ao_file_flash_flv |
| 58 | + |
| 59 | + if(remotefsize($remote_fl)<100000){ |
| 60 | + print "remote file: $remote_fl < 100k (skipping) \n"; |
| 61 | + continue; |
| 62 | + } |
57 | 63 | echo "DL it: $remote_fl \n"; |
58 | 64 | if(curldownload($remote_fl, $local_fl)){ |
59 | 65 | echo 'succesfully grabed '.$remote_fl."\n"; |
— | — | @@ -100,7 +106,7 @@ |
101 | 107 | if($i==2000){ |
102 | 108 | $i=0; |
103 | 109 | $lfs = filesize($file_target); |
104 | | - print formatbytes($lfs) .' of '. formatbytes($remote_size)." of $sn \n"; |
| 110 | + print hr_bytes($lfs) .' of '. hr_bytes($remote_size)." of $sn \n"; |
105 | 111 | clearstatcache(); |
106 | 112 | } |
107 | 113 | $i++; |
— | — | @@ -115,64 +121,45 @@ |
116 | 122 | fclose($wh); |
117 | 123 | return true; |
118 | 124 | } |
119 | | -function formatbytes($val, $digits = 4, $mode = "SI", $bB = "B"){ //$mode == "SI"|"IEC", $bB == "b"|"B" |
120 | | - $si = array("", "k", "M", "G", "T", "P", "E", "Z", "Y"); |
121 | | - $iec = array("", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi"); |
122 | | - switch(strtoupper($mode)) { |
123 | | - case "SI" : $factor = 1000; $symbols = $si; break; |
124 | | - case "IEC" : $factor = 1024; $symbols = $iec; break; |
125 | | - default : $factor = 1000; $symbols = $si; break; |
126 | | - } |
127 | | - switch($bB) { |
128 | | - case "b" : $val *= 8; break; |
129 | | - default : $bB = "B"; break; |
130 | | - } |
131 | | - for($i=0;$i<count($symbols)-1 && $val>=$factor;$i++) |
132 | | - $val /= $factor; |
133 | | - $p = strpos($val, "."); |
134 | | - if($p !== false && $p > $digits) $val = round($val); |
135 | | - elseif($p !== false) $val = round($val, $digits-$p); |
136 | | - return round($val, $digits) . " " . $symbols[$i] . $bB; |
137 | | - } |
138 | 125 | |
139 | | - function remotefsize($url) { |
140 | | - //$sch = parse_url($url, PHP_URL_SCHEME); |
141 | | - //if (($sch != "http") && ($sch != "https") && ($sch != "ftp") && ($sch != "ftps")) { |
142 | | - // return false; |
143 | | - //} |
144 | | - $sch='http'; |
145 | | - if (($sch == "http") || ($sch == "https")) { |
146 | | - $headers = get_headers($url, 1); |
147 | | - if ((!array_key_exists("Content-Length", $headers))) { return false; } |
148 | | - return $headers["Content-Length"]; |
| 126 | +function remotefsize($url) { |
| 127 | + //$sch = parse_url($url, PHP_URL_SCHEME); |
| 128 | + //if (($sch != "http") && ($sch != "https") && ($sch != "ftp") && ($sch != "ftps")) { |
| 129 | + // return false; |
| 130 | + //} |
| 131 | + $sch='http'; |
| 132 | + if (($sch == "http") || ($sch == "https")) { |
| 133 | + $headers = get_headers($url, 1); |
| 134 | + if ((!array_key_exists("Content-Length", $headers))) { return false; } |
| 135 | + return $headers["Content-Length"]; |
| 136 | + } |
| 137 | + if (($sch == "ftp") || ($sch == "ftps")) { |
| 138 | + $server = parse_url($url, PHP_URL_HOST); |
| 139 | + $port = parse_url($url, PHP_URL_PORT); |
| 140 | + $path = parse_url($url, PHP_URL_PATH); |
| 141 | + $user = parse_url($url, PHP_URL_USER); |
| 142 | + $pass = parse_url($url, PHP_URL_PASS); |
| 143 | + if ((!$server) || (!$path)) { return false; } |
| 144 | + if (!$port) { $port = 21; } |
| 145 | + if (!$user) { $user = "anonymous"; } |
| 146 | + if (!$pass) { $pass = "phpos@"; } |
| 147 | + switch ($sch) { |
| 148 | + case "ftp": |
| 149 | + $ftpid = ftp_connect($server, $port); |
| 150 | + break; |
| 151 | + case "ftps": |
| 152 | + $ftpid = ftp_ssl_connect($server, $port); |
| 153 | + break; |
149 | 154 | } |
150 | | - if (($sch == "ftp") || ($sch == "ftps")) { |
151 | | - $server = parse_url($url, PHP_URL_HOST); |
152 | | - $port = parse_url($url, PHP_URL_PORT); |
153 | | - $path = parse_url($url, PHP_URL_PATH); |
154 | | - $user = parse_url($url, PHP_URL_USER); |
155 | | - $pass = parse_url($url, PHP_URL_PASS); |
156 | | - if ((!$server) || (!$path)) { return false; } |
157 | | - if (!$port) { $port = 21; } |
158 | | - if (!$user) { $user = "anonymous"; } |
159 | | - if (!$pass) { $pass = "phpos@"; } |
160 | | - switch ($sch) { |
161 | | - case "ftp": |
162 | | - $ftpid = ftp_connect($server, $port); |
163 | | - break; |
164 | | - case "ftps": |
165 | | - $ftpid = ftp_ssl_connect($server, $port); |
166 | | - break; |
167 | | - } |
168 | | - if (!$ftpid) { return false; } |
169 | | - $login = ftp_login($ftpid, $user, $pass); |
170 | | - if (!$login) { return false; } |
171 | | - $ftpsize = ftp_size($ftpid, $path); |
172 | | - ftp_close($ftpid); |
173 | | - if ($ftpsize == -1) { return false; } |
174 | | - return $ftpsize; |
175 | | - } |
176 | | - } |
| 155 | + if (!$ftpid) { return false; } |
| 156 | + $login = ftp_login($ftpid, $user, $pass); |
| 157 | + if (!$login) { return false; } |
| 158 | + $ftpsize = ftp_size($ftpid, $path); |
| 159 | + ftp_close($ftpid); |
| 160 | + if ($ftpsize == -1) { return false; } |
| 161 | + return $ftpsize; |
| 162 | + } |
| 163 | +} |
177 | 164 | function simple_run_background($command){ |
178 | 165 | $PID = shell_exec("nohup $command > /dev/null & echo $!"); |
179 | 166 | return $PID; |
— | — | @@ -184,6 +171,7 @@ |
185 | 172 | return(count($ProcessState) >= 2); |
186 | 173 | } |
187 | 174 | function hr_bytes($size) { |
| 175 | + $size = (int)$size; |
188 | 176 | $a = array("B", "KB", "MB", "GB", "TB", "PB"); |
189 | 177 | $pos = 0; |
190 | 178 | while ($size >= 1024) { |
— | — | @@ -192,5 +180,4 @@ |
193 | 181 | } |
194 | 182 | return round($size,2)." ".$a[$pos]; |
195 | 183 | } |
196 | | - |
197 | 184 | ?> |
\ No newline at end of file |
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_StreamFile.php |
— | — | @@ -9,8 +9,7 @@ |
10 | 10 | * @email dale@ucsc.edu |
11 | 11 | * @url http://metavid.ucsc.edu |
12 | 12 | */ |
13 | | - if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
14 | | - |
| 13 | + if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
15 | 14 | /* |
16 | 15 | * MvStreamFile handles the mapping of path types to urls & |
17 | 16 | * active record style management of the mv_stream_files table |
— | — | @@ -27,15 +26,11 @@ |
28 | 27 | var $_parent_stream=null; |
29 | 28 | |
30 | 29 | //@@todo this should not be hard coded... read the header of the file? or extend path_type |
31 | | - var $msg_content_type_lookup = array( |
32 | | - 'ao_file_256Kb_MPEG4' =>'video/mp4', |
33 | | - 'ao_file_64Kb_MPEG4' =>'video/mp4', |
34 | | - 'ao_file_flash_flv' =>'video/x-flv', |
35 | | - 'ao_file_MPEG1' =>'video/mpeg', |
36 | | - 'ao_file_MPEG2' =>'video/mpeg-2', |
37 | | - 'mv_ogg_high_quality' =>'video/ogg', |
38 | | - 'mv_ogg_low_quality' =>'video/ogg' |
39 | | - ); |
| 30 | + function getTypeForQK($key){ |
| 31 | + global $mvMsgContentTypeLookup; |
| 32 | + if(isset($mvMsgContentTypeLookup[$key])) |
| 33 | + return $mvMsgContentTypeLookup[$key]; |
| 34 | + } |
40 | 35 | function __construct(&$parent_stream, $initRow=''){ |
41 | 36 | $this->_parent_stream =& $parent_stream; |
42 | 37 | //no init val.. populate from db |
— | — | @@ -54,8 +49,9 @@ |
55 | 50 | return $this->file_desc_msg; |
56 | 51 | } |
57 | 52 | function getContentType(){ |
58 | | - if(isset($this->msg_content_type_lookup[$this->file_desc_msg])){ |
59 | | - return $this->msg_content_type_lookup[$this->file_desc_msg]; |
| 53 | + global $mvMsgContentTypeLookup; |
| 54 | + if(isset($mvMsgContentTypeLookup[$this->file_desc_msg])){ |
| 55 | + return $mvMsgContentTypeLookup[$this->file_desc_msg]; |
60 | 56 | } |
61 | 57 | //default content type? |
62 | 58 | return 'application/octet-stream'; |
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_DefaultSettings.php |
— | — | @@ -92,6 +92,7 @@ |
93 | 93 | $mvVideoArchivePaths['cap1'] = 'http://128.114.20.64/media/'; |
94 | 94 | |
95 | 95 | $mvDefaultVideoQualityKey = 'mv_ogg_low_quality'; |
| 96 | +$mvDefaultFlashQualityKey = 'mv_flash_low_quality'; |
96 | 97 | |
97 | 98 | #local path to video archive (if hosted locally) |
98 | 99 | $mvLocalVideoLoc = '/metavid/video_archive'; |
— | — | @@ -179,6 +180,18 @@ |
180 | 181 | $wgGroupPermissions['bot']['mv_edit_stream']=true; |
181 | 182 | $wgAvailableRights[] = 'mv_delete_mvd'; |
182 | 183 | $wgAvailableRights[] = 'mv_edit_stream'; |
| 184 | + |
| 185 | +$mvMsgContentTypeLookup = array( |
| 186 | + 'ao_file_256Kb_MPEG4' =>'video/mp4', |
| 187 | + 'ao_file_64Kb_MPEG4' =>'video/mp4', |
| 188 | + 'ao_file_flash_flv' =>'video/x-flv', |
| 189 | + 'ao_file_MPEG1' =>'video/mpeg', |
| 190 | + 'ao_file_MPEG2' =>'video/mpeg-2', |
| 191 | + 'mv_flash_low_quality' =>'video/x-flv', |
| 192 | + 'mv_ogg_high_quality' =>'video/ogg', |
| 193 | + 'mv_ogg_low_quality' =>'video/ogg' |
| 194 | + ); |
| 195 | + |
183 | 196 | ### |
184 | 197 | # If you already have custom namespaces on your site, insert |
185 | 198 | # $mvNamespaceIndex = ???; in your config before including the settings |
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Title.php |
— | — | @@ -287,9 +287,9 @@ |
288 | 288 | 'stream_id' => $this->mvStream->id, |
289 | 289 | 'file_desc_msg'=>$quality |
290 | 290 | )); |
291 | | - $streamFile =$dbr->fetchObject($result); |
| 291 | + $streamFile =$dbr->fetchObject($result); |
292 | 292 | //make sure we have streamFiles (used to generate the link) |
293 | | - $mvStreamFile = new MV_StreamFile($this->mvStream); |
| 293 | + $mvStreamFile = new MV_StreamFile($this->mvStream, $streamFile); |
294 | 294 | //if link empty return false: |
295 | 295 | if($mvStreamFile->getFullURL()=='')return false; |
296 | 296 | return $mvStreamFile->getFullURL() . $anx_req; |
— | — | @@ -305,6 +305,7 @@ |
306 | 306 | return $roeTitle->getFullURL($query) ; |
307 | 307 | } |
308 | 308 | function getEmbedVideoHtml($vid_id='', $size='', $force_server='', $autoplay=false){ |
| 309 | + global $mvDefaultFlashQualityKey, $mvDefaultVideoQualityKey; |
309 | 310 | $tag='video'; |
310 | 311 | if($size==''){ |
311 | 312 | global $mvDefaultVideoPlaybackRes; |
— | — | @@ -314,7 +315,9 @@ |
315 | 316 | list($vWidth, $vHeight, $na) = MV_StreamImage::getSizeType($size); |
316 | 317 | } |
317 | 318 | $vid_id=($vid_id=='')?'':'id="'.$vid_id.'"'; |
318 | | - $stream_web_url = $this->getWebStreamURL(); |
| 319 | + $stream_web_url = $this->getWebStreamURL($mvDefaultVideoQualityKey); |
| 320 | + //print "lookign for q: $mvDefaultFlashQualityKey "; |
| 321 | + $flash_stream_url = $this->getWebStreamURL($mvDefaultFlashQualityKey); |
319 | 322 | $roe_url = $this->getROEURL(); |
320 | 323 | if($stream_web_url){ |
321 | 324 | $o=''; |
— | — | @@ -324,12 +327,19 @@ |
325 | 328 | '</span>'; |
326 | 329 | } |
327 | 330 | $auto_play_attr=($autoplay)?' autoplay="true" ':''; |
328 | | - $o.='<'.$tag.' '.$vid_id.' thumbnail="'.$this->getStreamImageURL($size, null, $force_server).'" '. |
329 | | - 'src="'.$stream_web_url .'" ' . |
| 331 | + $o.='<'.$tag.' '.$vid_id.' thumbnail="'.$this->getStreamImageURL($size, null, $force_server).'" '. |
330 | 332 | 'roe="'.$roe_url.'" '. |
331 | 333 | 'show_meta_link="false" ' . $auto_play_attr . |
332 | 334 | 'style="width:'.$vWidth.'px;height:'.$vHeight.'px" '. |
333 | | - 'controls="true" embed_link="true" />'; |
| 335 | + 'controls="true" embed_link="true" >'; |
| 336 | + |
| 337 | + if($stream_web_url!='') |
| 338 | + $o.='<source type="'.MV_StreamFile::getTypeForQK($mvDefaultVideoQualityKey).'" src="'.$stream_web_url .'"/>'; |
| 339 | + |
| 340 | + if($flash_stream_url!='') |
| 341 | + $o.='<source type="'.MV_StreamFile::getTypeForQK($mvDefaultFlashQualityKey).'" src="'.$flash_stream_url .'"/>'; |
| 342 | + |
| 343 | + $o.='</video>'; |
334 | 344 | return $o; |
335 | 345 | }else{ |
336 | 346 | return wfMsg('mv_error_stream_missing'); |
Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/flvServer/mvFlvServer.php |
— | — | @@ -33,6 +33,7 @@ |
34 | 34 | $file_req = $pathparts[count($pathparts)-1]; |
35 | 35 | } |
36 | 36 | } |
| 37 | +//print $file_req; |
37 | 38 | |
38 | 39 | //additional filtering to avoid directory traversing: |
39 | 40 | $file_req = str_replace(array('../','./'), '', $file_req); |