forked from HTTPArchive/legacy.httparchive.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame.php
41 lines (38 loc) · 1.21 KB
/
frame.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
require_once("ui.inc");
require_once("utils.inc");
require_once("dbapi.inc");
require_once("urls.inc");
require_once("pages.inc");
// Return a redirect to the filmstrip frame closest to but BEFORE the time specified.
$gTime = getParam('t', '2500'); // milliseconds
$wptid = getParam('wptid');
$wptrun = getParam('wptrun');
$gPageid = getParam('pageid');
$wptServer = wptServer(false);
$xmlurl = "http:{$wptServer}xmlResult.php?test=$wptid";
$xmlstr = fetchUrl($xmlurl);
$xml = new SimpleXMLElement($xmlstr);
$frames = $xml->data->run[($wptrun - 1)]->firstView->videoFrames;
$tbefore = 0;
$tafter = 0;
if ( $frames->frame ) {
foreach($frames->frame as $frame) {
// Find the time of a frame that is BEFORE the requested time.
$ms = floatval($frame->time) * 1000;
if ( $ms > $gTime ) {
$tafter = $ms;
break;
}
$tbefore = $ms;
}
}
$f = "0000" . ($tbefore/100);
$f = substr($f, strlen($f)-4);
if ( $gbMobile && "0000" == $f && $gPageid < 12217 ) {
// There's a bug in Blaze's WPT that calls the "0.0s" image "frame_0010.jpg" instead of "frame_0000.jpg" up until Oct 1, 2011.
$f = "0010";
}
$imgUrl = "{$wptServer}thumbnail.php?test=$wptid&width=200&file=video_$wptrun/frame_$f.jpg";
header("Location: $imgUrl");
?>