Changeset 950276
- Timestamp:
- 07/17/2014 12:51:44 PM (12 years ago)
- Location:
- busy-server/trunk
- Files:
-
- 3 edited
-
busy-server-admin.php (modified) (2 diffs)
-
busy-server.php (modified) (8 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
busy-server/trunk/busy-server-admin.php
r950226 r950276 1 1 <?php 2 defined( 'ABSPATH' ) or exit();3 2 /* 4 3 Busy Server Administration Panel 5 4 Plugin URI: https://github.com/gibboncz/busy-server 6 5 Description: When the server load is higher than specified, show an error message instead of loading the page. 7 Version: 0. 1.16 Version: 0.2 8 7 Author: Lubos Svoboda 9 8 */ 9 defined( 'ABSPATH' ) or exit(); 10 // Check that the user is allowed to update options 11 if (!current_user_can('manage_options')) { 12 wp_die('You do not have sufficient permissions to access this page.'); 13 } 10 14 ?> 11 15 <div class="wrap"> 12 16 <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> 13 19 <form method="post" action="options.php"> 14 20 <?php settings_fields( 'busy-server-group' ); ?> … … 17 23 <tr valign="top"> 18 24 <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> 20 26 </tr> 21 27 22 28 <tr valign="top"> 23 29 <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> 25 31 </tr> 26 32 -
busy-server/trunk/busy-server.php
r950234 r950276 2 2 /* 3 3 Plugin Name: Busy Server 4 Plugin URI: http s://github.com/gibboncz/busy-server4 Plugin URI: http://wordpress.org/plugins/busy-server/ 5 5 Description: When the server load is higher than specified, show an error message instead of loading the page. 6 Version: 0. 1.16 Version: 0.2 7 7 Author: Lubos Svoboda 8 8 */ … … 12 12 13 13 //TODO: check only when page not cached 14 15 14 //TODO: Logged in users can always 15 //if (is_user_logged_in()) ; 16 16 17 17 add_action('send_headers', 'busy_server_start'); … … 19 19 // admin actions 20 20 if ( 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' ); 23 23 } 24 25 24 26 25 … … 36 35 } 37 36 37 38 38 // Add admin options fields 39 39 function 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' ); 42 42 } 43 43 … … 64 64 } 65 65 } 66 */66 */ 67 67 } else return false; 68 68 } … … 73 73 if (!function_exists('busy_server_show')) { 74 74 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; 76 78 exit; 77 79 } … … 109 111 //windows 110 112 $cur_load = intval($load_arr[1]); 113 $max_load_win = floatval(get_option('busy_server_max_load')); 111 114 if ($cur_load > $max_load_win) 112 115 busy_server_show(); … … 115 118 //UNIX 116 119 $cur_load = busy_server_calculate_load($load_arr[0]); 120 $max_load_unix = floatval(get_option('busy_server_max_load')); 117 121 if ($cur_load > $max_load_unix) 118 122 busy_server_show(); -
busy-server/trunk/readme.txt
r950226 r950276 4 4 Requires at least: 3.4.2 5 5 Tested up to: 3.9.1 6 Stable tag: 0. 16 Stable tag: 0.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 41 41 = 0.1 = 42 42 Initial release 43 44 = 0.2 = 45 Custom error message and maximum load settings
Note: See TracChangeset
for help on using the changeset viewer.