<h2 id=pagespeed>PageSpeed</h2>

<?php 
if (!$gbMobile && !$gbAndroid && !$gbChrome) {
    // NOT mobile
    echo <<<OUTPUT
<style>
#pagespeedreport UL { max-width: 100%; }
</style>
<div id="pagespeedreport" style="margin-top: 10px; font-size: 0.9em;"></div>

<script type="text/javascript" src="{$wptServer}widgets/pagespeed/tree?test={$wptid}&div=pagespeedreport"></script>
OUTPUT;
} else {
    // mobile
    $file = BuildFileName($url);
    $fullpath = "./harfiles-delme/{$gPageid}.{$file}.har";
    $bWritten = false;
    if (strlen($file)) {
        $response = fetchUrl($harfileWptUrl);
        if (strlen($response)) {
            file_put_contents("{$fullpath}", $response);
            $bWritten = true;
        }
    }
    if ($bWritten) {
        doFile($fullpath);
        unlink($fullpath);
    }
    echo <<<OUTPUT
<script>
Exemple #2
0
    foreach ($results as &$result) {
        if (array_key_exists('id', $result) && strlen($result['id']) && array_key_exists('result', $result) && strlen($result['result'])) {
            $testCount++;
        }
    }
    if ($testCount) {
        echo "Retrieving HAR files for {$testCount} tests...\r\n";
        if (!is_dir('./har')) {
            mkdir('./har');
        }
        $count = 0;
        foreach ($results as &$result) {
            if (array_key_exists('id', $result) && strlen($result['id']) && array_key_exists('result', $result) && strlen($result['result'])) {
                $count++;
                echo "\rRetrieving HAR for test {$count} of {$testCount}...                  ";
                $file = $result['id'] . '-' . BuildFileName($result['url']);
                if (strlen($file) && !is_file("./har/{$file}.har")) {
                    $response = file_get_contents("{$server}export.php?test={$result['id']}&medianRun=fastest&run=median&bodies=1&pretty=1&cached=0");
                    if (strlen($response)) {
                        file_put_contents("./har/{$file}.har", $response);
                    }
                }
            }
        }
        // clear the progress text
        echo "\r                                                     \r";
        echo "Done\r\n";
    } else {
        echo "No HAR files available for download\r\n";
    }
} else {
Exemple #3
0
    foreach ($results as &$result) {
        if (strlen($result['id']) && strlen($result['result']) && $result['medianRun']) {
            $testCount++;
        }
    }
    if ($testCount) {
        echo "Retrieving HAR files for {$testCount} tests...\r\n";
        if (!is_dir('./har')) {
            mkdir('./har');
        }
        $count = 0;
        foreach ($results as &$result) {
            if (strlen($result['id']) && strlen($result['result']) && $result['medianRun']) {
                $count++;
                echo "\rRetrieving HAR for test {$count} of {$testCount}...                  ";
                $file = BuildFileName($result['url']);
                if (strlen($file) && !is_file("./har/{$file}.har")) {
                    $response = file_get_contents("{$server}export.php?test={$result['id']}&run={$result['medianRun']}&cached=0");
                    if (strlen($response)) {
                        file_put_contents("./har/{$file}.har", $response);
                    }
                }
            }
        }
        // clear the progress text
        echo "\r                                                     \r";
        echo "Done\r\n";
    } else {
        echo "No HAR files available for download\r\n";
    }
} else {