Plugin Directory

Changeset 2085883


Ignore:
Timestamp:
05/11/2019 12:05:50 PM (7 years ago)
Author:
wsec1
Message:

0.6.4 Added ttfb calculation (calculated on latest blog post url)

Location:
super-host-speed-benchmark/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • super-host-speed-benchmark/trunk/readme.txt

    r2085361 r2085883  
    51510.6.2 Change to speed formula
    52520.6.3 Report version number and stats
     530.6.4 Added ttfb calculation (calculated on latest blog post url)
    5354
    54 
  • super-host-speed-benchmark/trunk/shsb.php

    r2085361 r2085883  
    44* Plugin URI: https://superhostspeed.com/
    55* Description: Test and benchmark the speed of your hosting provider, based on the speed of their mysql database, which tends to be the main cause of Wordpress being slow on some hosts. A score of less than 40 is bad and a score of more than 100 is very good. Scores will be reported to our server in future versions so you can compare speeds with others. See Tools/Speed Benchmark
    6 * Version: 0.6.3
     6* Version: 0.6.4
    77* License: GPL2+
    88* Copyright 2019 Anthony Walker
     
    131131function shsb_calculate_score()
    132132{
    133     global $wpdb;
     133    global $wpdb,$ttfb;
    134134    $charset_collate = $wpdb->get_charset_collate();
    135135//$wpdb->show_errors();
     
    209209    $options = get_option( 'shsb_settings' );
    210210   
     211   
     212    //get_admin_url
     213   
     214   
     215   
     216 
     217    global $post;
     218    $placeholder = $post;
     219    $args = array(
     220        'numberposts'     => 1,
     221        'offset'          => 0,
     222        'orderby'         => 'post_date',
     223        'order'           => 'DESC',
     224        'post_status'     => 'publish' );
     225    $sorted_posts = get_posts( $args );
     226    $url = get_permalink($sorted_posts[0]->ID);
     227   
     228    $ttfb=shsb_get_ttfb($url);
     229    echo " | ttfb: $ttfb";
     230   
     231   
    211232    if ($options['shsb_checkbox_field_2']==0)
    212233    {
    213234    $plugin_data = get_plugin_data( __FILE__ );
    214235    $v = $plugin_data['Version'];
    215     $url="https://superhostspeed.com/benchmark.php?score=$score&h=".urlencode($options['shsb_text_field_0'])."&o=".urlencode($options['shsb_text_field_1'])."&host=".gethostname()."&ip=".$_SERVER['SERVER_ADDR']."&httphost=".$_SERVER['HTTP_HOST']."&version=$v&w=$ictr&r=$rctr";
     236    $url="https://superhostspeed.com/benchmark.php?score=$score&h=".urlencode($options['shsb_text_field_0'])."&o=".urlencode($options['shsb_text_field_1'])."&host=".gethostname()."&ip=".$_SERVER['SERVER_ADDR']."&httphost=".$_SERVER['HTTP_HOST']."&version=$v&w=$ictr&r=$rctr&ttfb=$ttfb";
    216237    //echo $url;
    217238    $r=file_get_contents($url);
     
    229250}
    230251// shsb_tools_page() displays the page content for the Test Tools submenu
     252
     253function shsb_get_ttfb($url)
     254{
     255   
     256     if (!function_exists('curl_version')) return 99999;
     257   
     258   
     259$ch = curl_init();
     260curl_setopt($ch, CURLOPT_URL, $url);
     261curl_setopt($ch, CURLOPT_HEADER, 0);
     262curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
     263curl_setopt($ch, CURLOPT_NOBODY, 1);
     264curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
     265
     266curl_exec($ch);
     267$info = curl_getinfo($ch);
     268curl_close($ch);
     269//var_dump($info);
     270//echo "<hr>\n";
     271return $info['starttransfer_time'];
     272}
     273
    231274function shsb_tools_page() {
    232275   
     
    250293    }
    251294   
     295   
    252296    $purl= plugins_url();
    253297   echo <<<EOT
     298   
    254299   <script src='$purl/super-host-speed-benchmark/gauge.min.js'></script>
    255300   
     
    314359 
    315360</script>
     361
     362<h2>
     363<a href='https://superhostspeed.com/' style="color:blue;text-align:center" target='_blank'>View ranking table<a>
     364</h2>
     365
    316366EOT;
    317367
Note: See TracChangeset for help on using the changeset viewer.