Plugin Directory

Changeset 950276


Ignore:
Timestamp:
07/17/2014 12:51:44 PM (12 years ago)
Author:
gibbon.cz
Message:

patch

Location:
busy-server/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • busy-server/trunk/busy-server-admin.php

    r950226 r950276  
    11<?php
    2 defined( 'ABSPATH' ) or exit();
    32/*
    43Busy Server Administration Panel
    54Plugin URI: https://github.com/gibboncz/busy-server
    65Description: When the server load is higher than specified, show an error message instead of loading the page.
    7 Version: 0.1.1
     6Version: 0.2
    87Author: Lubos Svoboda
    98*/
     9defined( 'ABSPATH' ) or exit();
     10// Check that the user is allowed to update options
     11if (!current_user_can('manage_options')) {
     12    wp_die('You do not have sufficient permissions to access this page.');
     13}
    1014?>
    1115<div class="wrap">
    1216    <h2>Busy Server Options</h2>
     17    <p><blockquote><strong>WARNING! Wrong settings can easily make your site unusable. Please modify only when you know what you are doing.</strong></blockquote></p>
     18    <p><blockquote><strong>Only Linux servers supported.</strong></blockquote></p>
    1319    <form method="post" action="options.php">
    1420        <?php settings_fields( 'busy-server-group' ); ?>
     
    1723            <tr valign="top">
    1824            <th scope="row">Maximum load per CPU core</th>
    19             <td ><input type="text" name="max_load" value="<?php echo get_option('max_load'); ?>" /></td>
     25            <td ><input type="number" step="0.01" name="busy_server_max_load" value="<?php echo get_option('busy_server_max_load'); ?>" /></td>
    2026            </tr>
    2127             
    2228            <tr valign="top">
    2329            <th scope="row">Custom Busy Message</th>
    24             <td title="Displayed when server is busy"><input type="text" name="busy_message" value="<?php echo get_option('busy_message'); ?>" /></td>
     30            <td title="Displayed when server is busy"><input type="text" name="busy_server_busy_message" size="50" value="<?php echo get_option('busy_server_busy_message'); ?>" /> <i>HTML or plain text</i></td>
    2531            </tr>
    2632
  • busy-server/trunk/busy-server.php

    r950234 r950276  
    22/*
    33Plugin Name: Busy Server
    4 Plugin URI: https://github.com/gibboncz/busy-server
     4Plugin URI: http://wordpress.org/plugins/busy-server/
    55Description: When the server load is higher than specified, show an error message instead of loading the page.
    6 Version: 0.1.1
     6Version: 0.2
    77Author: Lubos Svoboda
    88*/
     
    1212
    1313//TODO: check only when page not cached
    14 
    15 
     14//TODO: Logged in users can always
     15    //if (is_user_logged_in()) ;
    1616
    1717add_action('send_headers', 'busy_server_start');
     
    1919// admin actions
    2020if ( is_admin() ){
    21 //  add_action('admin_menu','busy_server_menu');
    22 //  add_action( 'admin_init', 'busy_server_mysettings' );
     21  add_action('admin_menu','busy_server_menu');
     22  add_action( 'admin_init', 'busy_server_mysettings' );
    2323}
    24 
    2524
    2625
     
    3635}
    3736
     37
    3838// Add admin options fields
    3939function busy_server_mysettings() { // whitelist options
    40   register_setting( 'busy-server-group', 'max_load' );
    41   register_setting( 'busy-server-group', 'busy_message' );
     40  register_setting( 'busy-server-group', 'busy_server_max_load' );
     41  register_setting( 'busy-server-group', 'busy_server_busy_message' );
    4242}
    4343
     
    6464                }
    6565            }   
    66             */     
     66             */     
    6767        }   else return false;
    6868    }
     
    7373if (!function_exists('busy_server_show')) {
    7474    function busy_server_show() {
    75         echo 'Server is busy. Please try reloading this page after few minutes.';
     75        $busy_msg = 'Server is busy. Please try reloading this page after few minutes.';
     76        $busy_msg = get_option('busy_server_busy_message');
     77        echo $busy_msg;
    7678        exit;
    7779    }
     
    109111                //windows
    110112                $cur_load = intval($load_arr[1]);
     113                $max_load_win = floatval(get_option('busy_server_max_load'));
    111114                if ($cur_load > $max_load_win)
    112115                    busy_server_show();
     
    115118            //UNIX
    116119                $cur_load = busy_server_calculate_load($load_arr[0]);
     120                $max_load_unix = floatval(get_option('busy_server_max_load'));
    117121                if ($cur_load > $max_load_unix)
    118122                    busy_server_show();
  • busy-server/trunk/readme.txt

    r950226 r950276  
    44Requires at least: 3.4.2
    55Tested up to: 3.9.1
    6 Stable tag: 0.1
     6Stable tag: 0.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4141= 0.1 =
    4242Initial release
     43
     44= 0.2 =
     45Custom error message and maximum load settings
Note: See TracChangeset for help on using the changeset viewer.