예제 #1
0
파일: view.php 프로젝트: kondrats/Pagetest
<?php

chdir('..');
include 'common.inc';
$id = $_REQUEST['id'];
$valid = false;
$done = false;
$ini = null;
$title = "Web page visual comparison";
$dir = GetVideoPath($id);
if (is_dir("./{$dir}")) {
    $valid = true;
    $ini = parse_ini_file("./{$dir}/video.ini");
    if (isset($ini['completed'])) {
        $done = true;
        GenerateThumbnail("./{$dir}");
    }
    // get the video time
    $date = date("M j, Y", filemtime("./{$dir}"));
    if (is_file("./{$dir}/video.mp4")) {
        $date = date("M j, Y", filemtime("./{$dir}/video.mp4"));
    }
    $title .= " - {$date}";
    $labels = json_decode(file_get_contents("./{$dir}/labels.txt"), true);
    if (count($labels)) {
        $title .= ' : ';
        foreach ($labels as $index => $label) {
            if ($index > 0) {
                $title .= ", ";
            }
            $title .= $label;
예제 #2
0
// file that gets uploaded.
$runNumber = arrayLookupWithDefault('_runNumber', $_REQUEST, null);
$runNumber = arrayLookupWithDefault('run', $_REQUEST, $runNumber);
$runIndex = arrayLookupWithDefault('index', $_REQUEST, null);
$cacheWarmed = arrayLookupWithDefault('_cacheWarmed', $_REQUEST, null);
$cacheWarmed = arrayLookupWithDefault('cached', $_REQUEST, $cacheWarmed);
$docComplete = arrayLookupWithDefault('_docComplete', $_REQUEST, null);
$onFullyLoaded = arrayLookupWithDefault('_onFullyLoaded', $_REQUEST, null);
$onRender = arrayLookupWithDefault('_onRender', $_REQUEST, null);
$urlUnderTest = arrayLookupWithDefault('_urlUnderTest', $_REQUEST, null);
$testInfo_dirty = false;
if (ValidateTestId($id)) {
    $testPath = './' . GetTestPath($id);
    if (array_key_exists('video', $_REQUEST) && $_REQUEST['video']) {
        logMsg("Video file {$id} received from {$_REQUEST['location']}");
        $dir = './' . GetVideoPath($id);
        if (array_key_exists('file', $_FILES) && array_key_exists('tmp_name', $_FILES['file'])) {
            if (!is_dir($dir)) {
                mkdir($dir, 0777, true);
            }
            $dest = $dir . '/video.mp4';
            move_uploaded_file($_FILES['file']['tmp_name'], $dest);
            @chmod($dest, 0666);
            $iniFile = $dir . '/video.ini';
            if (is_file($iniFile)) {
                $ini = file_get_contents($iniFile);
            } else {
                $ini = '';
            }
            $ini .= 'completed=' . gmdate('c') . "\r\n";
            file_put_contents($iniFile, $ini);
예제 #3
0
    }
}
if ($combineTimeLabel) {
    $labelHeight = 0;
}
$start = microtime(true);
// if FreeType isn't supported we can't draw text
$gdinfo = gd_info();
if (!isset($gdinfo['FreeType Support']) || !$gdinfo['FreeType Support']) {
    $labelHeight = 0;
    $timeHeight = 0;
}
// Load the information about the video that needs rendering
if (isset($_REQUEST['id'])) {
    $videoId = trim($_REQUEST['id']);
    $videoPath = './' . GetVideoPath($_REQUEST['id']);
    if (!is_file("{$videoPath}/video.ini")) {
        $optionsFile = "{$videoPath}/testinfo.json";
        if (gz_is_file($optionsFile)) {
            $tests = json_decode(gz_file_get_contents($optionsFile), true);
            if (isset($tests) && !is_array($tests)) {
                unset($tests);
            }
        }
    }
}
// Render the video
if (isset($tests) && count($tests)) {
    $lock = Lock("video-{$videoId}", false, 600);
    if ($lock) {
        RenderVideo($tests);
예제 #4
0
                 $id = $date . sha1($hashstr);
             } else {
                 $id = gmdate('ymd_') . md5(uniqid(rand(), true));
             }
         }
         $path = GetVideoPath($id);
         if (is_file("./{$path}/video.mp4")) {
             if ($_REQUEST['force']) {
                 delTree("./{$path}/");
             } else {
                 $exists = true;
             }
         }
         if (!$exists) {
             // set up the result directory
             $dest = './' . GetVideoPath($id);
             if (!is_dir($dest)) {
                 mkdir($dest, 0777, true);
             }
             if (count($labels)) {
                 file_put_contents("{$dest}/labels.txt", json_encode($labels));
             }
             gz_file_put_contents("{$dest}/testinfo.json", json_encode($tests));
             // kick off the actual rendering
             SendAsyncRequest("/video/render.php?id={$id}");
         }
     }
 }
 // redirect to the destination page
 if ($id) {
     $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
예제 #5
0
    $autoplay = 'true';
}
$page_keywords = array('Video', 'comparison', 'Webpagetest', 'Website Speed Test');
$page_description = "Side-by-side video comparison of website performance.";
$xml = false;
$json = false;
if (array_key_exists('f', $_REQUEST)) {
    if (!strcasecmp($_REQUEST['f'], 'xml')) {
        $xml = true;
    } elseif (!strcasecmp($_REQUEST['f'], 'json')) {
        $json = true;
    }
}
$ini = null;
$title = "WebPagetest - Visual Comparison";
$dir = GetVideoPath($videoId, true);
if (is_dir("./{$dir}")) {
    $valid = true;
    if (is_file("./{$dir}/video.mp4") || is_file("./{$dir}/video.ini")) {
        $ini = parse_ini_file("./{$dir}/video.ini");
        if (is_file("./{$dir}/video.mp4") || isset($ini['completed'])) {
            $done = true;
            GenerateVideoThumbnail("./{$dir}");
        }
    }
    // get the video time
    $date = gmdate("M j, Y", filemtime("./{$dir}"));
    if (is_file("./{$dir}/video.mp4")) {
        $date = gmdate("M j, Y", filemtime("./{$dir}/video.mp4"));
    }
    $title .= " - {$date}";
예제 #6
0
<?php

chdir('..');
include 'common.inc';
$id = $_REQUEST['id'];
$file = './' . GetVideoPath($id) . '/video.mp4';
if (ValidateTestId($id) && is_file($file)) {
    header('Content-disposition: attachment; filename=video.mp4');
    header('Content-type: video/mp4');
    readfile_chunked($file);
} else {
    ?>
<!DOCTYPE html>
<html>
    <head>
        <title>WebPagetest - Visual Comparison</title>
        <?php 
    $gaTemplate = 'Video Download Error';
    include 'head.inc';
    ?>
        <style type="text/css">
            div.content
            {
                text-align:center;
                background: black;
                color: white;
                font-family: arial,sans-serif
            }
            .link
            {
                text-decoration: none;