WordPress.org

Plugin Directory

Changeset 522916


Ignore:
Timestamp:
03/24/12 04:10:47 (2 years ago)
Author:
andrewryno
Message:

remove curl dependency and bump to 1.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • media-temple-server-status/trunk/media-temple-server-status.php

    r522457 r522916  
    44Plugin URI: http://andrewryno.com/plugins/media-temple-server-status/ 
    55Description: A dashboard widget that displays server status information for Media Temple servers. 
    6 Version: 1.0.1 
     6Version: 1.1 
    77Author: Andrew Ryno 
    88Author URI: http://andrewryno.com 
     
    1010*/ 
    1111 
    12 function mtss_curl_check() { 
    13     if  ( in_array( 'curl', get_loaded_extensions() ) ) { 
    14         return true; 
    15     } 
    16     else{ 
    17         return false; 
    18     } 
    19 } 
    20  
    2112register_uninstall_hook( __FILE__, 'mtss_uninstall_hook' ); 
    2213 
    2314add_action( 'admin_menu', 'mtss_plugin_menu' ); 
    2415add_action( 'wp_dashboard_setup', 'mtss_add_dashboard_widgets' ); 
    25  
    26 // Include the (mt) PHP API by Nathan Le Ray (modifications by Andrew Ryno) 
    27 require plugin_dir_path( __FILE__ ) . '/MtAPI.php'; 
    2816 
    2917// Display the Google Chart with (mt) server data on the dashboard 
     
    3725    } 
    3826     
    39     if ( ! mtss_curl_check() ) { 
    40         echo 'You must have cURL enabled on your server in order to use this plugin.'; 
    41         return; 
    42     } 
    43      
    44     // Create a new instance of the API and get the stats for the last hour 
    45     $mt = new MtAPI( $mtss_api_key, $mtss_service_id ); 
    46     $range_stats = $mt->get_predefined_range_stats( '1hour', array( 'cpu', 'memory', 'processes' ) ); 
     27    // Get the results from the API 
     28    $mt = json_decode( file_get_contents( 'https://api.mediatemple.net/api/v1/stats/' . $mtss_service_id . '/1hour.json?apikey=' . $mtss_api_key ) ); 
     29    $range_stats = $mt->statsList; 
    4730    ?> 
    4831    <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
     
    10790    } 
    10891     
    109     if ( ! mtss_curl_check() ) { 
    110         ?> 
    111         <div class="wrap"> 
    112             <div id="icon-options-general" class="icon32"><br></div> 
    113             <h2>(mt) Server Stats Options</h2> 
    114             <p>You must have cURL enabled on your server in order to use this plugin.</p> 
    115         </div> 
    116         <?php 
    117         return; 
    118     } 
    119      
    12092    // Check to see if the form was submitted 
    12193    if ( isset( $_POST['submit'] )) { 
     
    134106    // Allow the user to select services from a dropdown instead of inputting it themselves 
    135107    if ( ! empty( $mtss_api_key ) ) { 
    136         $mt = new MtAPI( $mtss_api_key ); 
    137         $services = $mt->get_services_list(); 
     108        $mt = json_decode( file_get_contents( 'https://api.mediatemple.net/api/v1/services.json?apikey=' .$mtss_api_key ) ); 
     109        $services = $mt->services; 
    138110    } 
    139111    ?> 
Note: See TracChangeset for help on using the changeset viewer.