Exemplo n.º 1
0
$test['video'] = 1;
$test['shard'] = 1;
if (!array_key_exists('priority', $_REQUEST)) {
    $req_priority = 0;
}
$test['median_video'] = 1;
$test['web10'] = 0;
$test['discard'] = 1;
$test['fvonly'] = 1;
//$test['script'] = "setDnsName\t%HOSTR%\tghs.google.com\noverrideHost\t%HOSTR%\tpsa.pssdemos.com\nnavigate\t%URL%";
$test['script'] = "addHeader\tModPagespeedFilters:combine_css,rewrite_css,inline_import_to_link,extend_cache,combine_javascript,rewrite_javascript,resize_images,move_css_to_head,rewrite_style_attributes_with_url,convert_png_to_jpeg,convert_jpeg_to_webp,recompress_images,convert_jpeg_to_progressive,convert_meta_tags,inline_css,inline_images,inline_javascript,lazyload_images,flatten_css_imports,inline_preview_images,defer_javascript,defer_iframe,add_instrumentation,flush_subresources,fallback_rewrite_css_urls,insert_dns_prefetch,split_html,prioritize_critical_css,convert_to_webp_lossless,convert_gif_to_png\t%HOST_REGEX%\n" . "if\trun\t1\n" . "if\tcached\t0\n" . "addHeader\tX-PSA-Blocking-Rewrite: pss_blocking_rewrite\t%HOST_REGEX%\n" . "endif\n" . "endif\n" . "setDnsName\t%HOSTR%\tghs.google.com\n" . "overrideHost\t%HOSTR%\tpsa.pssdemos.com\n" . "navigate\t%URL%";
$req_bulkurls = "Original={$req_url} noscript\nOptimized={$req_url}";
$test['label'] = "PageSpeed Service Comparison for {$req_url}";
// see if we have a cached test already
if (array_key_exists('url', $test) && strlen($test['url']) && (!array_key_exists('force', $_REQUEST) || $_REQUEST['force'] == 0)) {
    $cached_id = PSS_GetCacheEntry($test['url']);
    if (isset($cached_id) && strlen($cached_id)) {
        $test['id'] = $cached_id;
    }
}
if (!array_key_exists('id', $test)) {
    $test['submit_callback'] = 'PSS_TestSubmitted';
}
/**
* Get a cached test result
*/
function PSS_GetCacheEntry($url)
{
    $id = null;
    $cache_lock = Lock("PSS Cache");
    if (isset($cache_lock)) {
<?php

chdir('..');
include 'common.inc';
// response will always be JSON/JSONP
$id = null;
$ret = array();
if (array_key_exists('url', $_REQUEST) && strlen($_REQUEST['url'])) {
    $id = PSS_GetCacheEntry($_REQUEST['url']);
}
if (isset($id) && strlen($id)) {
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
    $host = $_SERVER['HTTP_HOST'];
    $ret['statusCode'] = 200;
    $ret['statusText'] = 'Ok';
    $ret['data'] = array();
    $ret['data']['testId'] = $id;
    $ret['data']['jsonUrl'] = "{$protocol}://{$host}/results.php?test={$id}&f=json";
    if (FRIENDLY_URLS) {
        $ret['data']['xmlUrl'] = "{$protocol}://{$host}/xmlResult/{$id}/";
        $ret['data']['userUrl'] = "{$protocol}://{$host}/result/{$id}/";
    } else {
        $ret['data']['xmlUrl'] = "{$protocol}://{$host}/xmlResult.php?test={$id}";
        $ret['data']['userUrl'] = "{$protocol}://{$host}/results.php?test={$id}";
    }
} else {
    $ret['statusCode'] = 404;
    $ret['statusText'] = 'Not Found';
}
json_response($ret);
/**